Skip to content

Commit

Permalink
move to cloud service
Browse files Browse the repository at this point in the history
  • Loading branch information
bakatrouble committed Jan 18, 2020
1 parent f5234eb commit f8f69f4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 94 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

Homebrew Nintendo Switch NSP sysmodule for automatic upload of screen captures to remote server.

Set host and port of a running server script in `/config/sys-screenuploader/config.ini`
For instructions see [http://screenuploader.bakatrouble.me](https://screenuploader.bakatrouble.me)

Server scripts are located in a `server` directory, feel free to make your ones and contribute to this repo.
[Website repo](https://github.com/bakatrouble/sys-screenuploader-web)

Currently implemented:
* Telegram

### Credits

Expand Down
5 changes: 3 additions & 2 deletions config.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[server]
host = home.bakatrouble.me
port = 60666
destination_id = undefined
; host =
; port =
5 changes: 3 additions & 2 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ using namespace std;

class Config {
public:
string host = "undefined";
long port = 0;
string destination_id = "undefined";
string host = "screenuploader.bakatrouble.me";
long port = 80;

static Config load();
};
21 changes: 0 additions & 21 deletions server/requirements.txt

This file was deleted.

62 changes: 0 additions & 62 deletions server/telegram_upload.py

This file was deleted.

5 changes: 3 additions & 2 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ Config Config::load() {
}

Config conf = {
reader.Get("server", "host", "undefined"),
reader.GetInteger("server", "port", 0)
reader.Get("server", "destination_id", "undefined"),
reader.Get("server", "host", "screenuploader.bakatrouble.me"),
reader.GetInteger("server", "port", 80),
};
return conf;
}
10 changes: 9 additions & 1 deletion src/sockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ u32 sendFileToServer(string &path, u32 size) {
Config conf = Config::load();
fs::path fpath(path);

if (conf.destination_id == "undefined") {
cout << "destination_id is not set in config" << endl;
}

int sockfd = socket(AF_INET, SOCK_STREAM, 0);

if (sockfd < 0) {
Expand Down Expand Up @@ -43,11 +47,12 @@ u32 sendFileToServer(string &path, u32 size) {
cout << "Building request" << endl;

stringstream ss;
ss << "POST /?filename=" << fpath.filename().string() << " HTTP/1.1\r\n"
ss << "POST /upload/" << conf.destination_id << "/?filename=" << fpath.filename().string() << " HTTP/1.1\r\n"
<< "Host: " << conf.host << ":" << conf.port << "\r\n"
<< "Content-Type: application/octet-stream\r\n"
<< "Content-Length: " << size << "\r\n"
<< "Content-Transfer-Encoding: binary\r\n"
<< "Connection: close\r\n"
<< "\r\n";
string request = ss.str();

Expand All @@ -69,6 +74,9 @@ u32 sendFileToServer(string &path, u32 size) {
bytesSent += send(sockfd, buf, readSize, 0);
}

int bytesRecv = recv(sockfd, buf, 0x2000u - 1, 0);
buf[bytesRecv] = 0;

f.close();
delete[] buf;

Expand Down

0 comments on commit f8f69f4

Please sign in to comment.