Fixups to initial Config
This commit is contained in:
Vendored
+21
-2
@@ -10,6 +10,25 @@
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(gdb) Attach",
|
||||
"type": "cppdbg",
|
||||
"request": "attach",
|
||||
"program": "enter program name, for example ${workspaceFolder}/a.out",
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
},
|
||||
{
|
||||
"description": "Set Disassembly Flavor to Intel",
|
||||
"text": "-gdb-set disassembly-flavor intel",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -290,9 +309,9 @@
|
||||
"program": "${command:cmake.launchTargetPath}",
|
||||
"args": [
|
||||
"--nosudo", // run without sudo (which will fail because of perms, but allow us to debug deeper into install code.)
|
||||
"--prefix", "/usr",
|
||||
"--disable-p2p"
|
||||
//"--get-current-port"
|
||||
"--install"
|
||||
//"--install"
|
||||
//"--enable-p2p" , "CA", "PiPedalTest","12345678","14"
|
||||
//"--list-p2p-channels"
|
||||
],
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace pipedal {
|
||||
std::string hotspotName_ = "pipedal";
|
||||
bool pinChanged_ = false;
|
||||
std::string pin_;
|
||||
std::string channel_ = "0"; // "0" -> select automatically.
|
||||
std::string channel_ = "1"; // "0" -> select automatically.
|
||||
std::string wlan_ = "wlan0";
|
||||
|
||||
void ParseArguments(const std::vector<std::string> &arguments);
|
||||
|
||||
Binary file not shown.
@@ -942,7 +942,7 @@ export class PiPedalModel //implements PiPedalModel
|
||||
return this.webSocket.connect();
|
||||
})
|
||||
.catch((error) => {
|
||||
this.setError("Failed to connect to server.");
|
||||
this.setError("Failed to connect to server." + error.toString());
|
||||
return false;
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
+49
-52
@@ -26,7 +26,7 @@ export type ReconnectHandler = () => void;
|
||||
export type ReconnectingHandler = (retry: number, maxRetries: number) => void;
|
||||
|
||||
const MAX_RETRIES = 6;
|
||||
const MAX_RETRY_TIME = 90*1000;
|
||||
const MAX_RETRY_TIME = 90 * 1000;
|
||||
|
||||
export type PiPedalMessageHeader = {
|
||||
replyTo?: number;
|
||||
@@ -37,10 +37,10 @@ type ReplyHandler = (header: PiPedalMessageHeader, body: any | null) => void;
|
||||
|
||||
|
||||
export interface PiPedalSocketListener {
|
||||
onMessageReceived : (header: PiPedalMessageHeader, body: any | null) => void;
|
||||
onMessageReceived: (header: PiPedalMessageHeader, body: any | null) => void;
|
||||
onError: (message: string, exception?: Error) => void;
|
||||
onConnectionLost: () => void;
|
||||
onReconnect: () => void;
|
||||
onReconnect: () => void;
|
||||
onReconnecting: (retry: number, maxRetries: number) => boolean;
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ class PiPedalSocket {
|
||||
constructor(
|
||||
url: string,
|
||||
listener: PiPedalSocketListener
|
||||
) {
|
||||
) {
|
||||
this.url = url;
|
||||
this.listener = listener;
|
||||
}
|
||||
@@ -103,8 +103,7 @@ class PiPedalSocket {
|
||||
|
||||
_replyMap: Map<number, ReplyHandler> = new Map<number, ReplyHandler>();
|
||||
|
||||
_discardReplyReservations()
|
||||
{
|
||||
_discardReplyReservations() {
|
||||
// it's ok. All pending reservations disappear into the GC.
|
||||
this._replyMap = new Map<number, ReplyHandler>();
|
||||
}
|
||||
@@ -193,8 +192,7 @@ class PiPedalSocket {
|
||||
return;
|
||||
|
||||
}
|
||||
if (this.canReconnect)
|
||||
{
|
||||
if (this.canReconnect) {
|
||||
this.listener.onConnectionLost();
|
||||
this._reconnect();
|
||||
}
|
||||
@@ -212,26 +210,23 @@ class PiPedalSocket {
|
||||
|
||||
isBackground: boolean = false;
|
||||
|
||||
enterBackgroundState()
|
||||
{
|
||||
enterBackgroundState() {
|
||||
this.isBackground = true;
|
||||
this.close();
|
||||
|
||||
}
|
||||
exitBackgroundState()
|
||||
{
|
||||
exitBackgroundState() {
|
||||
this.isBackground = false;
|
||||
this._reconnect();
|
||||
}
|
||||
|
||||
reconnect() {
|
||||
|
||||
if (this.socket)
|
||||
{
|
||||
if (this.socket) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
if (!this.listener.onReconnecting(this.retryCount,MAX_RETRIES)) {
|
||||
if (!this.listener.onReconnecting(this.retryCount, MAX_RETRIES)) {
|
||||
return;
|
||||
}
|
||||
++this.retryCount;
|
||||
@@ -243,8 +238,7 @@ class PiPedalSocket {
|
||||
this.listener.onReconnect();
|
||||
})
|
||||
.catch(error => {
|
||||
if (this.totalRetryDelay === MAX_RETRY_TIME)
|
||||
{
|
||||
if (this.totalRetryDelay >= MAX_RETRY_TIME) {
|
||||
this.listener.onError("Server connection lost.");
|
||||
return;
|
||||
} else {
|
||||
@@ -258,8 +252,7 @@ class PiPedalSocket {
|
||||
|
||||
close(): void {
|
||||
try {
|
||||
if (this.socket)
|
||||
{
|
||||
if (this.socket) {
|
||||
this.socket.onclose = null;
|
||||
this.socket.onerror = null;
|
||||
this.socket.onmessage = null;
|
||||
@@ -267,50 +260,54 @@ class PiPedalSocket {
|
||||
this.socket.close();
|
||||
this.socket = undefined;
|
||||
}
|
||||
} catch (ignored)
|
||||
{
|
||||
} catch (ignored) {
|
||||
|
||||
}
|
||||
this.socket = undefined;
|
||||
}
|
||||
connectInternal_(): Promise<WebSocket> {
|
||||
return new Promise<WebSocket>((resolve, reject) => {
|
||||
let ws = new WebSocket(this.url);
|
||||
try {
|
||||
let ws = new WebSocket(this.url);
|
||||
|
||||
let self = this;
|
||||
let self = this;
|
||||
|
||||
ws.onmessage = this.handleMessage.bind(this);
|
||||
ws.onclose = (event: Event) => {
|
||||
ws.onclose = null;
|
||||
ws.onerror = null;
|
||||
reject("Connection closed unexpectedly.");
|
||||
};
|
||||
ws.onerror = (event: Event) => {
|
||||
ws.onclose = null;
|
||||
ws.onerror = null;
|
||||
reject("Failed to connect.");
|
||||
};
|
||||
ws.onopen = (event: Event) => {
|
||||
ws.onerror = self.handleError.bind(self);
|
||||
ws.onclose = self.handleClose.bind(self);
|
||||
ws.onopen = null;
|
||||
resolve(ws);
|
||||
ws.onmessage = this.handleMessage.bind(this);
|
||||
ws.onclose = (event: Event) => {
|
||||
ws.onclose = null;
|
||||
ws.onerror = null;
|
||||
reject("Connection closed unexpectedly.");
|
||||
};
|
||||
ws.onerror = (event: Event) => {
|
||||
ws.onclose = null;
|
||||
ws.onerror = null;
|
||||
reject("Failed to connect.");
|
||||
};
|
||||
ws.onopen = (event: Event) => {
|
||||
ws.onerror = self.handleError.bind(self);
|
||||
ws.onclose = self.handleClose.bind(self);
|
||||
alert("Web socket connected."); //yyy
|
||||
ws.onopen = null;
|
||||
resolve(ws);
|
||||
};
|
||||
} catch (e: any){
|
||||
reject("Failed to connect. " + e.toString());
|
||||
};
|
||||
});
|
||||
}
|
||||
connect(): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
}
|
||||
connect(): Promise < void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
|
||||
this.connectInternal_()
|
||||
.then((socket) => {
|
||||
this.socket = socket;
|
||||
resolve();
|
||||
})
|
||||
.catch((reason) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
this.connectInternal_()
|
||||
.then((socket) => {
|
||||
this.socket = socket;
|
||||
resolve();
|
||||
})
|
||||
.catch((reason) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+22
-9
@@ -771,7 +771,8 @@ void DeployVarConfig()
|
||||
void InstallPgpKey()
|
||||
{
|
||||
fs::path homeDir = "/var/pipedal/config/gpg";
|
||||
fs::path keyPath = "/etc/pipedal/config/updatekey.gpg";
|
||||
fs::path keyPath = "/etc/pipedal/config/updatekey.asc";
|
||||
fs::path keyPath2 = "/etc/pipedal/config/updatekey2.asc";
|
||||
|
||||
fs::create_directories(homeDir);
|
||||
std::ignore = chmod(homeDir.c_str(), 0700);
|
||||
@@ -781,15 +782,26 @@ void InstallPgpKey()
|
||||
s << (CHOWN_BIN " " SERVICE_GROUP_NAME ":" SERVICE_GROUP_NAME " ") << homeDir.c_str();
|
||||
sysExec(s.str().c_str());
|
||||
}
|
||||
std::ostringstream ss;
|
||||
ss << "/usr/bin/gpg --homedir " << homeDir.c_str() << " --import " << keyPath.c_str();
|
||||
|
||||
int rc = silentSysExec(ss.str().c_str());
|
||||
if (rc != EXIT_SUCCESS)
|
||||
{
|
||||
cout << "Error: Failed to create update keyring." << endl;
|
||||
}
|
||||
std::ostringstream ss;
|
||||
ss << "/usr/bin/gpg --homedir " << homeDir.c_str() << " --import " << keyPath.c_str();
|
||||
int rc = silentSysExec(ss.str().c_str());
|
||||
if (rc != EXIT_SUCCESS)
|
||||
{
|
||||
cout << "Error: Failed to create update keyring." << endl;
|
||||
}
|
||||
|
||||
}
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "/usr/bin/gpg --homedir " << homeDir.c_str() << " --import " << keyPath2.c_str();
|
||||
int rc = silentSysExec(ss.str().c_str());
|
||||
if (rc != EXIT_SUCCESS)
|
||||
{
|
||||
cout << "Error: Failed to add update key." << endl;
|
||||
}
|
||||
|
||||
}
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << (CHOWN_BIN " -R " SERVICE_GROUP_NAME ":" SERVICE_GROUP_NAME " ") << homeDir.c_str();
|
||||
@@ -1396,10 +1408,11 @@ int main(int argc, char **argv)
|
||||
else if (disable_p2p)
|
||||
{
|
||||
WifiDirectConfigSettings settings;
|
||||
settings.valid_ = true;
|
||||
settings.Load();
|
||||
settings.enable_ = false;
|
||||
SetWifiDirectConfig(settings);
|
||||
RestartService(true);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else if (enable_ap)
|
||||
{
|
||||
|
||||
@@ -559,6 +559,13 @@ void UninstallP2p()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (UsingNetworkManager())
|
||||
{
|
||||
// dhcpcd comes up enabled after an install, so stop it always.
|
||||
sysExec(SYSTEMCTL_BIN " stop dhcpcd");
|
||||
sysExec(SYSTEMCTL_BIN " disable dhcpcd");
|
||||
|
||||
}
|
||||
::sync();
|
||||
}
|
||||
|
||||
+3
-6
@@ -847,14 +847,13 @@ void Updater::ValidateSignature(const std::filesystem::path &file, const std::fi
|
||||
}
|
||||
std::string keyId = getFingerprint(gpgText);
|
||||
|
||||
Lv2Log::info(unCRLF(gpgText)); // yyy delete me.
|
||||
|
||||
if (keyId != UPDATE_GPG_FINGERPRINT)
|
||||
if (keyId != UPDATE_GPG_FINGERPRINT && keyId != UPDATE_GPG_FINGERPRINT2)
|
||||
{
|
||||
throw std::runtime_error(SS("Update signature has the wrong fingerprint: " << keyId));
|
||||
throw std::runtime_error(SS("Update signature has the wrong id: " << keyId));
|
||||
}
|
||||
std::string origin = getAddress(gpgText);
|
||||
if (origin != UPDATE_GPG_ADDRESS)
|
||||
if (origin != UPDATE_GPG_ADDRESS && origin != UPDATE_GPG_ADDRESS2)
|
||||
{
|
||||
throw std::runtime_error(SS("Update signature has an incorrect address." << origin));
|
||||
}
|
||||
@@ -934,7 +933,6 @@ void Updater::DownloadUpdate(const std::string &url, std::filesystem::path *file
|
||||
responseOption = "-w \"%%{response_code}\""; // windows shell requires doubling of the %%.
|
||||
#endif
|
||||
std::string args = SS("-s -L " << responseOption << " " << url << " -o " << downloadFilePath.c_str());
|
||||
Lv2Log::info(SS("/usr/bin/curl " << args)); // yyy delete me.
|
||||
auto curlOutput = sysExecForOutput("/usr/bin/curl", args);
|
||||
if (curlOutput.exitCode != EXIT_SUCCESS || badOutput(downloadFilePath))
|
||||
{
|
||||
@@ -944,7 +942,6 @@ void Updater::DownloadUpdate(const std::string &url, std::filesystem::path *file
|
||||
checkCurlHttpResponse(curlOutput.output);
|
||||
|
||||
args = SS("-s -L " << responseOption << " " << signatureUrl << " -o " << downloadSignaturePath.c_str());
|
||||
Lv2Log::info(SS("/usr/bin/curl " << args));
|
||||
|
||||
curlOutput = sysExecForOutput("/usr/bin/curl", args);
|
||||
if (curlOutput.exitCode != EXIT_SUCCESS || badOutput(downloadSignaturePath))
|
||||
|
||||
@@ -42,10 +42,17 @@
|
||||
#ifndef UPDATE_GPG_ADDRESS
|
||||
#define UPDATE_GPG_ADDRESS "Robin Davies <rerdavies@gmail.com>"
|
||||
#endif
|
||||
#ifndef UPDATE_GPG_ADDRESS2
|
||||
#define UPDATE_GPG_ADDRESS2 "PiPedal Project <rerdavies@gmail.com>"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef UPDATE_GPG_FINGERPRINT
|
||||
#define UPDATE_GPG_FINGERPRINT "381124E2BB4478D225D2313B2AEF3F7BD53EAA59"
|
||||
#endif
|
||||
#ifndef UPDATE_GPG_FINGERPRINT2
|
||||
#define UPDATE_GPG_FINGERPRINT2 "2D1F39DBB1F819412B678F88E9D7081E08E3D85C"
|
||||
#endif
|
||||
|
||||
// Configuration for downloading of updates.
|
||||
|
||||
|
||||
@@ -401,7 +401,6 @@ public:
|
||||
|
||||
if (patchProperty.length() == 0 && directory.length() == 0)
|
||||
{
|
||||
// yyy no throwing!
|
||||
throw PiPedalException("Malformed request.");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user