A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory

update

+11 -12
+11 -12
cmd/plcbundle/main.go
··· 811 fs := flag.NewFlagSet("serve", flag.ExitOnError) 812 port := fs.String("port", "8080", "HTTP server port") 813 host := fs.String("host", "127.0.0.1", "HTTP server host") 814 - mirror := fs.Bool("mirror", false, "enable mirror mode (auto-sync from PLC)") 815 - plcURL := fs.String("plc", "https://plc.directory", "PLC directory URL (for mirror mode)") 816 - syncInterval := fs.Duration("sync-interval", 5*time.Minute, "sync interval for mirror mode") 817 fs.Parse(os.Args[2:]) 818 819 - // Create manager with PLC client if mirror mode is enabled 820 var plcURLForManager string 821 - if *mirror { 822 plcURLForManager = *plcURL 823 } 824 ··· 835 fmt.Printf(" Directory: %s\n", dir) 836 fmt.Printf(" Listening: http://%s\n", addr) 837 838 - if *mirror { 839 - fmt.Printf(" Mirror mode: ENABLED\n") 840 fmt.Printf(" PLC URL: %s\n", *plcURL) 841 fmt.Printf(" Sync interval: %s\n", *syncInterval) 842 - fmt.Printf(" Mempool API: ENABLED\n") // Added 843 } else { 844 - fmt.Printf(" Mirror mode: disabled\n") 845 } 846 847 fmt.Printf("\nPress Ctrl+C to stop\n\n") 848 849 - // Start mirror sync if enabled 850 ctx, cancel := context.WithCancel(context.Background()) 851 defer cancel() 852 853 - if *mirror { 854 go runSync(ctx, mgr, *syncInterval) 855 } 856 857 server := &http.Server{ 858 Addr: addr, 859 - Handler: newServerHandler(mgr, *mirror), // Pass mirror flag 860 ReadTimeout: 30 * time.Second, 861 WriteTimeout: 30 * time.Second, 862 }
··· 811 fs := flag.NewFlagSet("serve", flag.ExitOnError) 812 port := fs.String("port", "8080", "HTTP server port") 813 host := fs.String("host", "127.0.0.1", "HTTP server host") 814 + sync := fs.Bool("sync", false, "enable sync mode (auto-sync from PLC)") 815 + plcURL := fs.String("plc", "https://plc.directory", "PLC directory URL (for sync mode)") 816 + syncInterval := fs.Duration("sync-interval", 5*time.Minute, "sync interval for sync mode") 817 fs.Parse(os.Args[2:]) 818 819 + // Create manager with PLC client if sync mode is enabled 820 var plcURLForManager string 821 + if *sync { 822 plcURLForManager = *plcURL 823 } 824 ··· 835 fmt.Printf(" Directory: %s\n", dir) 836 fmt.Printf(" Listening: http://%s\n", addr) 837 838 + if *sync { 839 + fmt.Printf(" Sync mode: ENABLED\n") 840 fmt.Printf(" PLC URL: %s\n", *plcURL) 841 fmt.Printf(" Sync interval: %s\n", *syncInterval) 842 } else { 843 + fmt.Printf(" Sync mode: disabled\n") 844 } 845 846 fmt.Printf("\nPress Ctrl+C to stop\n\n") 847 848 + // Start sync if enabled 849 ctx, cancel := context.WithCancel(context.Background()) 850 defer cancel() 851 852 + if *sync { 853 go runSync(ctx, mgr, *syncInterval) 854 } 855 856 server := &http.Server{ 857 Addr: addr, 858 + Handler: newServerHandler(mgr, *sync), 859 ReadTimeout: 30 * time.Second, 860 WriteTimeout: 30 * time.Second, 861 }