Add public key to peer info and implement public key generation from private key
This commit is contained in:
@@ -46,6 +46,19 @@ class VpnSessionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generates public key from private key
|
||||||
|
static Future<String> _getPublicKeyFromPrivateKey(String privateKey) async {
|
||||||
|
try {
|
||||||
|
final pubProcess = await Process.start('wg', ['pubkey']);
|
||||||
|
pubProcess.stdin.writeln(privateKey);
|
||||||
|
await pubProcess.stdin.close();
|
||||||
|
final publicKey = await pubProcess.stdout.transform(utf8.decoder).join();
|
||||||
|
return publicKey.trim();
|
||||||
|
} catch (e) {
|
||||||
|
return 'Error generating public key: $e';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Gets keepalive info for a specific peer
|
/// Gets keepalive info for a specific peer
|
||||||
static Future<String> _getKeepaliveForPeer(String publicKey) async {
|
static Future<String> _getKeepaliveForPeer(String publicKey) async {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class PeerRoutes {
|
|||||||
'peer': {
|
'peer': {
|
||||||
'ip': peer.ip,
|
'ip': peer.ip,
|
||||||
'privateKey': peer.privateKey,
|
'privateKey': peer.privateKey,
|
||||||
|
'publicKey': peer.publicKey,
|
||||||
},
|
},
|
||||||
'server': {
|
'server': {
|
||||||
'publicKey': serverPublicKey,
|
'publicKey': serverPublicKey,
|
||||||
|
|||||||
Reference in New Issue
Block a user