diff --git a/compose.yaml b/compose.yaml index 8b0c086..4123bf7 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,6 +2,7 @@ services: netgate-switch: build: . pull_policy: build + container_name: NetgateSwitch ports: - '7000:7000' restart: unless-stopped diff --git a/index.ts b/index.ts index e7f1341..92836b0 100644 --- a/index.ts +++ b/index.ts @@ -72,9 +72,12 @@ const server = serve({ if (!haslogin) return new Response('ROS配置未设置', { status: 401 }); const sockaddr = server.requestIP(request); - let ipaddr = sockaddr === null ? '' : sockaddr.address; + let ipinfo = sockaddr === null ? '' : sockaddr.address; + let ipaddr = ipinfo.split(':'); console.log(sockaddr); - return new Response(JSON.stringify(await getDHCPList(ipaddr))); + return new Response( + JSON.stringify(await getDHCPList(ipaddr[ipaddr.length - 1])) + ); } if (url.pathname === '/core/switch/') {