Files
MeshPort/engines/singbox/cmd/meshport-singbox/main.go
T
shenleiandClaude Haiku 5.5 2f185f914d Snapshot uncommitted work: proxy UI, sing-box integration, socks bridge
- Lab app: proxy panel, node editor, configuration and detail pages,
  responsive layout, and related tests
- Add meshport-socks crate and sing-box bridge scripts/docs
- Add singbox_flutter binding and meshport_client_core package
- FFI, VPN helper (unified mac path), and Android/macOS runner updates
- Docs for architecture, client runtime, UI design, and validation
- UI design output artifacts under outputs/ui

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-12 10:06:15 +09:00

60 lines
1.4 KiB
Go

package main
import (
"context"
"encoding/json"
"fmt"
"io"
"os"
"os/signal"
"syscall"
"meshport.local/singbox/bridge"
)
func run() error {
if len(os.Args) != 2 {
return fmt.Errorf("usage: meshport-singbox MANAGED-CONFIG.json")
}
file, err := os.Open(os.Args[1])
if err != nil {
return fmt.Errorf("cannot read managed configuration")
}
defer file.Close()
info, err := file.Stat()
if err != nil || info.Size() > 65536 {
return fmt.Errorf("managed configuration exceeds size limit or cannot be read")
}
decoder := json.NewDecoder(io.LimitReader(file, 65537))
decoder.DisallowUnknownFields()
var config bridge.Config
if err = decoder.Decode(&config); err != nil {
return fmt.Errorf("invalid managed configuration")
}
var extra any
if decoder.Decode(&extra) != io.EOF {
return fmt.Errorf("invalid trailing configuration")
}
var engine bridge.Engine
if err = engine.Start(context.Background(), config); err != nil {
return err
}
defer engine.Stop()
// One machine-readable readiness line, no configuration/credentials/log dump.
if err = json.NewEncoder(os.Stdout).Encode(engine.Snapshot()); err != nil {
return err
}
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
defer signal.Stop(stop)
<-stop
return engine.Stop()
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}