mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-02 05:23:14 +00:00
endpoint for getting config
This commit is contained in:
@@ -8,22 +8,23 @@ import { Observable } from 'rxjs'
|
||||
})
|
||||
export abstract class ApiService {
|
||||
abstract openWebsocket$<T>(guid: string): Observable<T>
|
||||
abstract subscribe(): Promise<SubscribeRes>
|
||||
abstract subscribe(): Promise<SubscribeRes> // db.subscribe
|
||||
// auth
|
||||
abstract login(params: LoginReq): Promise<null>
|
||||
abstract logout(): Promise<null>
|
||||
abstract setPassword(params: LoginReq): Promise<null>
|
||||
abstract login(params: LoginReq): Promise<null> // auth.login
|
||||
abstract logout(): Promise<null> // auth.logout
|
||||
abstract setPassword(params: LoginReq): Promise<null> // auth.set-password
|
||||
// subnets
|
||||
abstract addSubnet(params: UpsertSubnetReq): Promise<null>
|
||||
abstract editSubnet(params: UpsertSubnetReq): Promise<null>
|
||||
abstract deleteSubnet(params: DeleteSubnetReq): Promise<null>
|
||||
abstract addSubnet(params: UpsertSubnetReq): Promise<null> // subnet.add
|
||||
abstract editSubnet(params: UpsertSubnetReq): Promise<null> // subnet.add
|
||||
abstract deleteSubnet(params: DeleteSubnetReq): Promise<null> // subnet.remove
|
||||
// devices
|
||||
abstract addDevice(params: UpsertDeviceReq): Promise<null>
|
||||
abstract editDevice(params: UpsertDeviceReq): Promise<null>
|
||||
abstract deleteDevice(params: DeleteDeviceReq): Promise<null>
|
||||
abstract addDevice(params: UpsertDeviceReq): Promise<null> // device.add
|
||||
abstract editDevice(params: UpsertDeviceReq): Promise<null> // device.add
|
||||
abstract deleteDevice(params: DeleteDeviceReq): Promise<null> // device.remove
|
||||
abstract showDeviceConfig(params: DeleteDeviceReq): Promise<string> // device.show-config
|
||||
// forwards
|
||||
abstract addForward(params: AddForwardReq): Promise<null>
|
||||
abstract deleteForward(params: DeleteForwardReq): Promise<null>
|
||||
abstract addForward(params: AddForwardReq): Promise<null> // forward.add
|
||||
abstract deleteForward(params: DeleteForwardReq): Promise<null> // forward.remove
|
||||
}
|
||||
|
||||
export type SubscribeRes = {
|
||||
|
||||
@@ -70,7 +70,7 @@ export class LiveApiService extends ApiService {
|
||||
}
|
||||
|
||||
async deleteSubnet(params: DeleteSubnetReq): Promise<null> {
|
||||
return this.rpcRequest({ method: 'subnet.delete', params })
|
||||
return this.rpcRequest({ method: 'subnet.remove', params })
|
||||
}
|
||||
|
||||
// devices
|
||||
@@ -84,27 +84,31 @@ export class LiveApiService extends ApiService {
|
||||
}
|
||||
|
||||
async deleteDevice(params: DeleteDeviceReq): Promise<null> {
|
||||
return this.rpcRequest({ method: 'device.delete', params })
|
||||
return this.rpcRequest({ method: 'device.remove', params })
|
||||
}
|
||||
|
||||
async showDeviceConfig(params: DeleteDeviceReq): Promise<string> {
|
||||
return this.rpcRequest({ method: 'device.show-config', params })
|
||||
}
|
||||
|
||||
// forwards
|
||||
|
||||
async addForward(params: AddForwardReq): Promise<null> {
|
||||
return this.rpcRequest({ method: 'forward.create', params })
|
||||
return this.rpcRequest({ method: 'forward.add', params })
|
||||
}
|
||||
|
||||
async deleteForward(params: DeleteForwardReq): Promise<null> {
|
||||
return this.rpcRequest({ method: 'forward.delete', params })
|
||||
return this.rpcRequest({ method: 'forward.remove', params })
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
private async upsertSubnet(params: UpsertSubnetReq): Promise<null> {
|
||||
return this.rpcRequest({ method: 'subnet.upsert', params })
|
||||
return this.rpcRequest({ method: 'subnet.add', params })
|
||||
}
|
||||
|
||||
private async upsertDevice(params: UpsertDeviceReq): Promise<null> {
|
||||
return this.rpcRequest({ method: 'device.upsert', params })
|
||||
return this.rpcRequest({ method: 'device.add', params })
|
||||
}
|
||||
|
||||
private async rpcRequest<T>(
|
||||
|
||||
@@ -161,6 +161,12 @@ export class MockApiService extends ApiService {
|
||||
return null
|
||||
}
|
||||
|
||||
async showDeviceConfig(params: DeleteDeviceReq): Promise<string> {
|
||||
await pauseFor(1000)
|
||||
|
||||
return MOCK_CONFIG
|
||||
}
|
||||
|
||||
async addForward(params: AddForwardReq): Promise<null> {
|
||||
await pauseFor(1000)
|
||||
|
||||
@@ -202,3 +208,21 @@ export class MockApiService extends ApiService {
|
||||
function replaceSlashes(val: string) {
|
||||
return val.replace(new RegExp('/', 'g'), '~1')
|
||||
}
|
||||
|
||||
const MOCK_CONFIG = `[Interface]
|
||||
# Server's private IP address for the WireGuard VPN subnet
|
||||
Address = 10.20.10.1/24
|
||||
# UDP port WireGuard listens on
|
||||
ListenPort = 33333
|
||||
# Server private key (generated)
|
||||
PrivateKey = 4K68mdpQWdEz/FpdVuRoZYgWpQgpW63J9GFzn+iOulQ=
|
||||
|
||||
# Commands to run after starting/stopping WireGuard tunnel to enable forwarding and NAT (example)
|
||||
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
||||
|
||||
# Add client peers below with their public keys and allowed IPs
|
||||
[Peer]
|
||||
# Client public key
|
||||
PublicKey = MQBiYHxAj7u8paj3L4w4uav3P/9YBPbaN4gkWn90SSs=
|
||||
# Allowed client IP address within VPN subnet`
|
||||
|
||||
Reference in New Issue
Block a user