| 84 | |
| 85 | |
| 86 | type SingBoxEngine struct { |
| 87 | mu sync.Mutex |
| 88 | running atomic.Bool |
| 89 | log *logger.Logger |
| 90 | cancel context.CancelFunc |
| 91 | configPath string |
| 92 | instance *box.Box |
| 93 | |
| 94 | // savedCfg / savedCtx are the original Start args, kept so ApplyAppWhitelist |
| 95 | // can rebuild the sing-box config in-place without reconstructing the |
| 96 | // caller's intent. They are only meaningful while running. |
| 97 | savedCfg EngineConfig |
| 98 | savedCtx context.Context |
| 99 | |
| 100 | |
| 101 | uploadBytes atomic.Int64 |
| 102 | downloadBytes atomic.Int64 |
| 103 | |
| 104 | // proxyUploadBytes/proxyDownloadBytes count ONLY traffic carried by the |
| 105 | // proxy/endpoint outbound (the tracker increments them only when the matched |
| 106 | // outbound is not direct/block). The watchdog's traffic veto reads these so |
| 107 | // direct/split-tunnel traffic cannot make a dead upstream look alive. |
| 108 | proxyUploadBytes atomic.Int64 |
| 109 | proxyDownloadBytes atomic.Int64 |
| 110 | } |
| 111 | |
| 112 | |
| 113 | type singBoxLogWriter struct { |
nothing calls this directly
no outgoing calls
no test coverage detected