File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,18 +2,11 @@ pub mod protocol;
22pub mod peer_identity;
33
44pub use interprocess:: local_socket:: tokio:: { LocalSocketListener , LocalSocketStream } ;
5- #[ cfg( unix) ]
6- use std:: os:: unix:: io:: AsRawFd ;
7- #[ cfg( windows) ]
8- use std:: os:: windows:: io:: AsRawHandle ;
9-
10- use crate :: peer_identity:: { PeerIdentity , get_peer_identity} ;
115
126// Re-export protocol
137pub use protocol:: { BridgeService , BridgeServiceClient , BridgeError } ;
148
159use tarpc:: server:: { BaseChannel , Channel } ;
16- use tokio:: io:: { AsyncRead , AsyncWrite } ;
1710use futures:: StreamExt ;
1811
1912pub struct BridgeServer ;
Original file line number Diff line number Diff line change 1- use std:: io;
2-
31#[ derive( Debug , Clone , Copy ) ]
42pub struct PeerIdentity {
53 pub uid : Option < u32 > ,
Original file line number Diff line number Diff line change 1+ use anyhow:: Result ;
2+ use clap:: { Args , Subcommand } ;
3+ use localgpt_core:: security:: BridgeManager ;
4+
5+ #[ derive( Args ) ]
6+ pub struct BridgeArgs {
7+ #[ command( subcommand) ]
8+ pub command : BridgeCommands ,
9+ }
10+
11+ #[ derive( Subcommand ) ]
12+ pub enum BridgeCommands {
13+ /// Register a new bridge with credentials
14+ Register {
15+ /// Unique ID for the bridge (e.g., "telegram")
16+ #[ arg( long) ]
17+ id : String ,
18+
19+ /// Secret key/token for the bridge
20+ #[ arg( long) ]
21+ secret : String ,
22+ } ,
23+ }
24+
25+ pub async fn run ( args : BridgeArgs ) -> Result < ( ) > {
26+ match args. command {
27+ BridgeCommands :: Register { id, secret } => {
28+ let manager = BridgeManager :: new ( ) ;
29+ manager. register_bridge ( & id, secret. as_bytes ( ) ) . await ?;
30+ // Note: Logging is handled by the core logging system, initialized in main.
31+ // But we can print to stdout for CLI feedback.
32+ println ! ( "Bridge '{}' registered successfully." , id) ;
33+ println ! ( "You may need to restart the daemon for changes to take effect." ) ;
34+ }
35+ }
36+ Ok ( ( ) )
37+ }
Original file line number Diff line number Diff line change 11pub mod ask;
22pub mod auth;
3+ pub mod bridge;
34pub mod chat;
45pub mod config;
56pub mod daemon;
@@ -81,4 +82,7 @@ pub enum Commands {
8182
8283 /// Authenticate with providers (Gemini, etc.)
8384 Auth ( auth:: AuthArgs ) ,
85+
86+ /// Manage bridges and credentials
87+ Bridge ( bridge:: BridgeArgs ) ,
8488}
Original file line number Diff line number Diff line change @@ -85,5 +85,6 @@ async fn async_main(cli: Cli) -> Result<()> {
8585 Commands :: Sandbox ( args) => crate :: cli:: sandbox:: run ( args) . await ,
8686 Commands :: Search ( args) => crate :: cli:: search:: run ( args) . await ,
8787 Commands :: Auth ( args) => crate :: cli:: auth:: run ( args) . await ,
88+ Commands :: Bridge ( args) => crate :: cli:: bridge:: run ( args) . await ,
8889 }
8990}
You can’t perform that action at this time.
0 commit comments