MCPcopy
hub / github.com/windtf/wireproxy / main

Function main

cmd/wireproxy/main.go:157–270  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

155}
156
157func main() {
158 s := make(chan os.Signal, 1)
159 signal.Notify(s, syscall.SIGINT, syscall.SIGQUIT)
160 ctx, cancel := context.WithCancel(context.Background())
161
162 go func() {
163 <-s
164 cancel()
165 }()
166
167 exePath := executablePath()
168 lock("boot")
169
170 isDaemonProcess := len(os.Args) > 1 && os.Args[1] == daemonProcess
171 args := os.Args
172 if isDaemonProcess {
173 lock("boot-daemon")
174 args = []string{args[0]}
175 args = append(args, os.Args[2:]...)
176 }
177 parser := argparse.NewParser("wireproxy", "Userspace wireguard client for proxying")
178
179 config := parser.String("c", "config", &argparse.Options{Help: "Path of configuration file"})
180 silent := parser.Flag("s", "silent", &argparse.Options{Help: "Silent mode"})
181 daemon := parser.Flag("d", "daemon", &argparse.Options{Help: "Make wireproxy run in background"})
182 info := parser.String("i", "info", &argparse.Options{Help: "Specify the address and port for exposing health status"})
183 printVerison := parser.Flag("v", "version", &argparse.Options{Help: "Print version"})
184 configTest := parser.Flag("n", "configtest", &argparse.Options{Help: "Configtest mode. Only check the configuration file for validity."})
185
186 err := parser.Parse(args)
187 if err != nil {
188 fmt.Print(parser.Usage(err))
189 return
190 }
191
192 if *printVerison {
193 fmt.Printf("wireproxy, version %s\n", version)
194 return
195 }
196
197 if *config == "" {
198 if path, config_exist := configFilePath(); config_exist {
199 *config = path
200 } else {
201 fmt.Println("configuration path is required")
202 return
203 }
204 }
205
206 if !*daemon {
207 lock("read-config")
208 }
209
210 conf, err := wireproxy.ParseConfig(*config)
211 if err != nil {
212 log.Fatal(err)
213 }
214

Callers

nothing calls this directly

Calls 9

ParseConfigFunction · 0.92
StartWireguardFunction · 0.92
executablePathFunction · 0.85
lockFunction · 0.85
configFilePathFunction · 0.85
lockNetworkFunction · 0.85
StartPingIPsMethod · 0.80
ListenAndServeMethod · 0.80
SpawnRoutineMethod · 0.65

Tested by

no test coverage detected