Skip to content

Commit 0ca2a9a

Browse files
committed
Merge pull request #362 from uProxy/dborkan-install
Update installer to return invite object instead of URL
2 parents e15f080 + 668b62b commit 0ca2a9a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/cloud/install/freedom-module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"install": {
1414
"type": "method",
1515
"value": ["string", "number", "string", "string"],
16-
"ret": "string"
16+
"ret": "object"
1717
},
1818
"err": {
1919
"message": "string"

src/cloud/install/installer.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var log: logging.Log = new logging.Log('cloud installer');
1818
const INSTALL_COMMAND = 'curl -sSL https://raw.githubusercontent.com/uProxy/uproxy-docker/master/install-cloud.sh | sh';
1919

2020
// Prefix for invitation URLs.
21-
const INVITATION_URL_PREFIX = 'https://www.uproxy.org/invite/';
21+
const INVITATION_PREFIX = 'CLOUD_INSTANCE_DETAILS_JSON:';
2222

2323
// Installs uProxy on a server, via SSH.
2424
// The process is as close as possible to a manual install
@@ -31,7 +31,7 @@ class CloudInstaller {
3131
host:string,
3232
port:number,
3333
username:string,
34-
key:string) : Promise<string> => {
34+
key:string) : Promise<Object> => {
3535
log.debug('installing uproxy on %1:%2 as %3', host, port, username);
3636

3737
const connectConfig: ssh2.ConnectConfig = {
@@ -55,8 +55,15 @@ class CloudInstaller {
5555
// Search for the URL anywhere in the line so we will
5656
// continue to work in the face of minor changes
5757
// to the install script.
58-
if (line.indexOf(INVITATION_URL_PREFIX) === 0) {
59-
F(line.substring(INVITATION_URL_PREFIX.length));
58+
if (line.indexOf(INVITATION_PREFIX) === 0) {
59+
const inviteJson = line.substring(INVITATION_PREFIX.length);
60+
try {
61+
F(JSON.parse(inviteJson));
62+
} catch (e) {
63+
R({
64+
message: 'could not parse invite: ' + inviteJson
65+
});
66+
}
6067
}
6168
});
6269

0 commit comments

Comments
 (0)