tangled
alpha
login
or
join now
atscan.net
/
plcbundle
A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory
14
fork
atom
overview
issues
2
pulls
pipelines
update
tree.fail
3 months ago
40ffa60d
fe8753bd
+11
-12
1 changed file
expand all
collapse all
unified
split
cmd
plcbundle
main.go
+11
-12
cmd/plcbundle/main.go
···
811
811
fs := flag.NewFlagSet("serve", flag.ExitOnError)
812
812
port := fs.String("port", "8080", "HTTP server port")
813
813
host := fs.String("host", "127.0.0.1", "HTTP server host")
814
814
-
mirror := fs.Bool("mirror", false, "enable mirror mode (auto-sync from PLC)")
815
815
-
plcURL := fs.String("plc", "https://plc.directory", "PLC directory URL (for mirror mode)")
816
816
-
syncInterval := fs.Duration("sync-interval", 5*time.Minute, "sync interval for mirror mode")
814
814
+
sync := fs.Bool("sync", false, "enable sync mode (auto-sync from PLC)")
815
815
+
plcURL := fs.String("plc", "https://plc.directory", "PLC directory URL (for sync mode)")
816
816
+
syncInterval := fs.Duration("sync-interval", 5*time.Minute, "sync interval for sync mode")
817
817
fs.Parse(os.Args[2:])
818
818
819
819
-
// Create manager with PLC client if mirror mode is enabled
819
819
+
// Create manager with PLC client if sync mode is enabled
820
820
var plcURLForManager string
821
821
-
if *mirror {
821
821
+
if *sync {
822
822
plcURLForManager = *plcURL
823
823
}
824
824
···
835
835
fmt.Printf(" Directory: %s\n", dir)
836
836
fmt.Printf(" Listening: http://%s\n", addr)
837
837
838
838
-
if *mirror {
839
839
-
fmt.Printf(" Mirror mode: ENABLED\n")
838
838
+
if *sync {
839
839
+
fmt.Printf(" Sync mode: ENABLED\n")
840
840
fmt.Printf(" PLC URL: %s\n", *plcURL)
841
841
fmt.Printf(" Sync interval: %s\n", *syncInterval)
842
842
-
fmt.Printf(" Mempool API: ENABLED\n") // Added
843
842
} else {
844
844
-
fmt.Printf(" Mirror mode: disabled\n")
843
843
+
fmt.Printf(" Sync mode: disabled\n")
845
844
}
846
845
847
846
fmt.Printf("\nPress Ctrl+C to stop\n\n")
848
847
849
849
-
// Start mirror sync if enabled
848
848
+
// Start sync if enabled
850
849
ctx, cancel := context.WithCancel(context.Background())
851
850
defer cancel()
852
851
853
853
-
if *mirror {
852
852
+
if *sync {
854
853
go runSync(ctx, mgr, *syncInterval)
855
854
}
856
855
857
856
server := &http.Server{
858
857
Addr: addr,
859
859
-
Handler: newServerHandler(mgr, *mirror), // Pass mirror flag
858
858
+
Handler: newServerHandler(mgr, *sync),
860
859
ReadTimeout: 30 * time.Second,
861
860
WriteTimeout: 30 * time.Second,
862
861
}