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
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"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}",
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
"args": [
|
"args": [
|
||||||
"--nosudo", // run without sudo (which will fail because of perms, but allow us to debug deeper into install code.)
|
"--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"
|
//"--get-current-port"
|
||||||
"--install"
|
//"--install"
|
||||||
//"--enable-p2p" , "CA", "PiPedalTest","12345678","14"
|
//"--enable-p2p" , "CA", "PiPedalTest","12345678","14"
|
||||||
//"--list-p2p-channels"
|
//"--list-p2p-channels"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace pipedal {
|
|||||||
std::string hotspotName_ = "pipedal";
|
std::string hotspotName_ = "pipedal";
|
||||||
bool pinChanged_ = false;
|
bool pinChanged_ = false;
|
||||||
std::string pin_;
|
std::string pin_;
|
||||||
std::string channel_ = "0"; // "0" -> select automatically.
|
std::string channel_ = "1"; // "0" -> select automatically.
|
||||||
std::string wlan_ = "wlan0";
|
std::string wlan_ = "wlan0";
|
||||||
|
|
||||||
void ParseArguments(const std::vector<std::string> &arguments);
|
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();
|
return this.webSocket.connect();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.setError("Failed to connect to server.");
|
this.setError("Failed to connect to server." + error.toString());
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
+49
-52
@@ -26,7 +26,7 @@ export type ReconnectHandler = () => void;
|
|||||||
export type ReconnectingHandler = (retry: number, maxRetries: number) => void;
|
export type ReconnectingHandler = (retry: number, maxRetries: number) => void;
|
||||||
|
|
||||||
const MAX_RETRIES = 6;
|
const MAX_RETRIES = 6;
|
||||||
const MAX_RETRY_TIME = 90*1000;
|
const MAX_RETRY_TIME = 90 * 1000;
|
||||||
|
|
||||||
export type PiPedalMessageHeader = {
|
export type PiPedalMessageHeader = {
|
||||||
replyTo?: number;
|
replyTo?: number;
|
||||||
@@ -37,10 +37,10 @@ type ReplyHandler = (header: PiPedalMessageHeader, body: any | null) => void;
|
|||||||
|
|
||||||
|
|
||||||
export interface PiPedalSocketListener {
|
export interface PiPedalSocketListener {
|
||||||
onMessageReceived : (header: PiPedalMessageHeader, body: any | null) => void;
|
onMessageReceived: (header: PiPedalMessageHeader, body: any | null) => void;
|
||||||
onError: (message: string, exception?: Error) => void;
|
onError: (message: string, exception?: Error) => void;
|
||||||
onConnectionLost: () => void;
|
onConnectionLost: () => void;
|
||||||
onReconnect: () => void;
|
onReconnect: () => void;
|
||||||
onReconnecting: (retry: number, maxRetries: number) => boolean;
|
onReconnecting: (retry: number, maxRetries: number) => boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class PiPedalSocket {
|
|||||||
constructor(
|
constructor(
|
||||||
url: string,
|
url: string,
|
||||||
listener: PiPedalSocketListener
|
listener: PiPedalSocketListener
|
||||||
) {
|
) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
@@ -103,8 +103,7 @@ class PiPedalSocket {
|
|||||||
|
|
||||||
_replyMap: Map<number, ReplyHandler> = new Map<number, ReplyHandler>();
|
_replyMap: Map<number, ReplyHandler> = new Map<number, ReplyHandler>();
|
||||||
|
|
||||||
_discardReplyReservations()
|
_discardReplyReservations() {
|
||||||
{
|
|
||||||
// it's ok. All pending reservations disappear into the GC.
|
// it's ok. All pending reservations disappear into the GC.
|
||||||
this._replyMap = new Map<number, ReplyHandler>();
|
this._replyMap = new Map<number, ReplyHandler>();
|
||||||
}
|
}
|
||||||
@@ -193,8 +192,7 @@ class PiPedalSocket {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (this.canReconnect)
|
if (this.canReconnect) {
|
||||||
{
|
|
||||||
this.listener.onConnectionLost();
|
this.listener.onConnectionLost();
|
||||||
this._reconnect();
|
this._reconnect();
|
||||||
}
|
}
|
||||||
@@ -212,26 +210,23 @@ class PiPedalSocket {
|
|||||||
|
|
||||||
isBackground: boolean = false;
|
isBackground: boolean = false;
|
||||||
|
|
||||||
enterBackgroundState()
|
enterBackgroundState() {
|
||||||
{
|
|
||||||
this.isBackground = true;
|
this.isBackground = true;
|
||||||
this.close();
|
this.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
exitBackgroundState()
|
exitBackgroundState() {
|
||||||
{
|
|
||||||
this.isBackground = false;
|
this.isBackground = false;
|
||||||
this._reconnect();
|
this._reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnect() {
|
reconnect() {
|
||||||
|
|
||||||
if (this.socket)
|
if (this.socket) {
|
||||||
{
|
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.listener.onReconnecting(this.retryCount,MAX_RETRIES)) {
|
if (!this.listener.onReconnecting(this.retryCount, MAX_RETRIES)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
++this.retryCount;
|
++this.retryCount;
|
||||||
@@ -243,8 +238,7 @@ class PiPedalSocket {
|
|||||||
this.listener.onReconnect();
|
this.listener.onReconnect();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (this.totalRetryDelay === MAX_RETRY_TIME)
|
if (this.totalRetryDelay >= MAX_RETRY_TIME) {
|
||||||
{
|
|
||||||
this.listener.onError("Server connection lost.");
|
this.listener.onError("Server connection lost.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -258,8 +252,7 @@ class PiPedalSocket {
|
|||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
try {
|
try {
|
||||||
if (this.socket)
|
if (this.socket) {
|
||||||
{
|
|
||||||
this.socket.onclose = null;
|
this.socket.onclose = null;
|
||||||
this.socket.onerror = null;
|
this.socket.onerror = null;
|
||||||
this.socket.onmessage = null;
|
this.socket.onmessage = null;
|
||||||
@@ -267,50 +260,54 @@ class PiPedalSocket {
|
|||||||
this.socket.close();
|
this.socket.close();
|
||||||
this.socket = undefined;
|
this.socket = undefined;
|
||||||
}
|
}
|
||||||
} catch (ignored)
|
} catch (ignored) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this.socket = undefined;
|
this.socket = undefined;
|
||||||
}
|
}
|
||||||
connectInternal_(): Promise<WebSocket> {
|
connectInternal_(): Promise<WebSocket> {
|
||||||
return new Promise<WebSocket>((resolve, reject) => {
|
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.onmessage = this.handleMessage.bind(this);
|
||||||
ws.onclose = (event: Event) => {
|
ws.onclose = (event: Event) => {
|
||||||
ws.onclose = null;
|
ws.onclose = null;
|
||||||
ws.onerror = null;
|
ws.onerror = null;
|
||||||
reject("Connection closed unexpectedly.");
|
reject("Connection closed unexpectedly.");
|
||||||
};
|
};
|
||||||
ws.onerror = (event: Event) => {
|
ws.onerror = (event: Event) => {
|
||||||
ws.onclose = null;
|
ws.onclose = null;
|
||||||
ws.onerror = null;
|
ws.onerror = null;
|
||||||
reject("Failed to connect.");
|
reject("Failed to connect.");
|
||||||
};
|
};
|
||||||
ws.onopen = (event: Event) => {
|
ws.onopen = (event: Event) => {
|
||||||
ws.onerror = self.handleError.bind(self);
|
ws.onerror = self.handleError.bind(self);
|
||||||
ws.onclose = self.handleClose.bind(self);
|
ws.onclose = self.handleClose.bind(self);
|
||||||
ws.onopen = null;
|
alert("Web socket connected."); //yyy
|
||||||
resolve(ws);
|
ws.onopen = null;
|
||||||
|
resolve(ws);
|
||||||
|
};
|
||||||
|
} catch (e: any){
|
||||||
|
reject("Failed to connect. " + e.toString());
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect(): Promise<void> {
|
connect(): Promise < void> {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
|
|
||||||
this.connectInternal_()
|
this.connectInternal_()
|
||||||
.then((socket) => {
|
.then((socket) => {
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.catch((reason) => {
|
.catch((reason) => {
|
||||||
reject(reason);
|
reject(reason);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-9
@@ -771,7 +771,8 @@ void DeployVarConfig()
|
|||||||
void InstallPgpKey()
|
void InstallPgpKey()
|
||||||
{
|
{
|
||||||
fs::path homeDir = "/var/pipedal/config/gpg";
|
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);
|
fs::create_directories(homeDir);
|
||||||
std::ignore = chmod(homeDir.c_str(), 0700);
|
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();
|
s << (CHOWN_BIN " " SERVICE_GROUP_NAME ":" SERVICE_GROUP_NAME " ") << homeDir.c_str();
|
||||||
sysExec(s.str().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;
|
std::stringstream ss;
|
||||||
ss << (CHOWN_BIN " -R " SERVICE_GROUP_NAME ":" SERVICE_GROUP_NAME " ") << homeDir.c_str();
|
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)
|
else if (disable_p2p)
|
||||||
{
|
{
|
||||||
WifiDirectConfigSettings settings;
|
WifiDirectConfigSettings settings;
|
||||||
settings.valid_ = true;
|
settings.Load();
|
||||||
settings.enable_ = false;
|
settings.enable_ = false;
|
||||||
SetWifiDirectConfig(settings);
|
SetWifiDirectConfig(settings);
|
||||||
RestartService(true);
|
RestartService(true);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
else if (enable_ap)
|
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();
|
::sync();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -847,14 +847,13 @@ void Updater::ValidateSignature(const std::filesystem::path &file, const std::fi
|
|||||||
}
|
}
|
||||||
std::string keyId = getFingerprint(gpgText);
|
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);
|
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));
|
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 %%.
|
responseOption = "-w \"%%{response_code}\""; // windows shell requires doubling of the %%.
|
||||||
#endif
|
#endif
|
||||||
std::string args = SS("-s -L " << responseOption << " " << url << " -o " << downloadFilePath.c_str());
|
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);
|
auto curlOutput = sysExecForOutput("/usr/bin/curl", args);
|
||||||
if (curlOutput.exitCode != EXIT_SUCCESS || badOutput(downloadFilePath))
|
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);
|
checkCurlHttpResponse(curlOutput.output);
|
||||||
|
|
||||||
args = SS("-s -L " << responseOption << " " << signatureUrl << " -o " << downloadSignaturePath.c_str());
|
args = SS("-s -L " << responseOption << " " << signatureUrl << " -o " << downloadSignaturePath.c_str());
|
||||||
Lv2Log::info(SS("/usr/bin/curl " << args));
|
|
||||||
|
|
||||||
curlOutput = sysExecForOutput("/usr/bin/curl", args);
|
curlOutput = sysExecForOutput("/usr/bin/curl", args);
|
||||||
if (curlOutput.exitCode != EXIT_SUCCESS || badOutput(downloadSignaturePath))
|
if (curlOutput.exitCode != EXIT_SUCCESS || badOutput(downloadSignaturePath))
|
||||||
|
|||||||
@@ -42,10 +42,17 @@
|
|||||||
#ifndef UPDATE_GPG_ADDRESS
|
#ifndef UPDATE_GPG_ADDRESS
|
||||||
#define UPDATE_GPG_ADDRESS "Robin Davies <rerdavies@gmail.com>"
|
#define UPDATE_GPG_ADDRESS "Robin Davies <rerdavies@gmail.com>"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef UPDATE_GPG_ADDRESS2
|
||||||
|
#define UPDATE_GPG_ADDRESS2 "PiPedal Project <rerdavies@gmail.com>"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef UPDATE_GPG_FINGERPRINT
|
#ifndef UPDATE_GPG_FINGERPRINT
|
||||||
#define UPDATE_GPG_FINGERPRINT "381124E2BB4478D225D2313B2AEF3F7BD53EAA59"
|
#define UPDATE_GPG_FINGERPRINT "381124E2BB4478D225D2313B2AEF3F7BD53EAA59"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef UPDATE_GPG_FINGERPRINT2
|
||||||
|
#define UPDATE_GPG_FINGERPRINT2 "2D1F39DBB1F819412B678F88E9D7081E08E3D85C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Configuration for downloading of updates.
|
// Configuration for downloading of updates.
|
||||||
|
|
||||||
|
|||||||
@@ -401,7 +401,6 @@ public:
|
|||||||
|
|
||||||
if (patchProperty.length() == 0 && directory.length() == 0)
|
if (patchProperty.length() == 0 && directory.length() == 0)
|
||||||
{
|
{
|
||||||
// yyy no throwing!
|
|
||||||
throw PiPedalException("Malformed request.");
|
throw PiPedalException("Malformed request.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user