root | 59a69f8 | 2025-06-05 08:35:22 +0000 | [diff] [blame] | 1 | package tracker; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | import java.net.InetSocketAddress; |
| 5 | |
| 6 | import org.simpleframework.http.core.ContainerServer; |
| 7 | import org.simpleframework.transport.connect.Connection; |
| 8 | import org.simpleframework.transport.connect.SocketConnection; |
| 9 | |
| 10 | import entity.config; |
| 11 | |
| 12 | /** |
| 13 | * 启动 DataCaptureProxy: |
| 14 | * 客户端将 announce 请求发到本机 capturePort, |
| 15 | * 由 DataCaptureProxy 拦截并转发到 trackerHost:trackerPort。 |
| 16 | */ |
| 17 | public class DataCaptureServer { |
| 18 | |
| 19 | public static void start() throws IOException { |
| 20 | String trackerHost = config.trackerHost; |
| 21 | int trackerPort = config.trackerPort; |
| 22 | int capturePort = config.capturePort; |
| 23 | |
| 24 | DataCaptureProxy proxy = new DataCaptureProxy(trackerHost, trackerPort); |
| 25 | ContainerServer server = new ContainerServer(proxy); |
| 26 | Connection conn = new SocketConnection(server); |
| 27 | |
| 28 | conn.connect(new InetSocketAddress(capturePort)); |
| 29 | System.out.println("DataCapture proxy listening on port " |
| 30 | + capturePort + ", forwarding to " |
| 31 | + trackerHost + ":" + trackerPort); |
| 32 | } |
| 33 | } |