MCPcopy Create free account
hub / github.com/Hidden-Node/GooseRelayVPN-AndroidClient / StartClient

Function StartClient

mobile/mobile.go:80–204  ·  view source on GitHub ↗
(configPath string, logPath string)

Source from the content-addressed store, hash-verified

78}
79
80func StartClient(configPath string, logPath string) error {
81 mu.Lock()
82 if running {
83 mu.Unlock()
84 return fmt.Errorf("client is already running")
85 }
86 mu.Unlock()
87
88 bytesMu.Lock()
89 totalUploadBytes = 0
90 totalDownloadBytes = 0
91 bytesMu.Unlock()
92
93 if err := os.MkdirAll(filepath.Dir(logPath), 0o755); err != nil {
94 return fmt.Errorf("create log directory: %w", err)
95 }
96 logFile, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644)
97 if err != nil {
98 return fmt.Errorf("open log file: %w", err)
99 }
100 defer logFile.Close()
101 log.SetFlags(0)
102 log.SetOutput(logFile)
103
104 cfg, err := config.LoadClient(configPath)
105 if err != nil {
106 return err
107 }
108
109 carr, err := carrier.New(carrier.Config{
110 ScriptURLs: cfg.ScriptURLs,
111 ScriptAccounts: cfg.ScriptAccounts,
112 AESKeyHex: cfg.AESKeyHex,
113 DebugTiming: cfg.DebugTiming,
114 CoalesceStep: time.Duration(cfg.CoalesceStepMs) * time.Millisecond,
115 CoalesceMax: time.Duration(cfg.CoalesceMaxMs) * time.Millisecond,
116 IdleSlotsPerBucket: cfg.IdleSlotsPerBucket,
117 Fronting: carrier.FrontingConfig{
118 GoogleIP: cfg.GoogleIP,
119 SNIHosts: cfg.SNIHosts,
120 },
121 })
122 if err != nil {
123 return fmt.Errorf("carrier init failed: %w", err)
124 }
125
126 ctx, cancel := context.WithCancel(context.Background())
127 done := make(chan struct{})
128 mu.Lock()
129 cancelFn = cancel
130 clientDone = done
131 running = true
132 mu.Unlock()
133
134 go func() {
135 if err := carr.Run(ctx); err != nil && ctx.Err() == nil {
136 log.Printf("[client] carrier run error: %v", err)
137 }

Callers

nothing calls this directly

Calls 5

LoadClientFunction · 0.92
NewFunction · 0.92
CloseMethod · 0.80
RunMethod · 0.80
NewSessionMethod · 0.80

Tested by

no test coverage detected