88import java .net .MalformedURLException ;
99import java .net .ProtocolException ;
1010import java .net .URL ;
11+ import java .util .Date ;
1112import java .util .HashMap ;
1213import java .util .Map ;
1314import java .util .concurrent .Executors ;
@@ -34,20 +35,27 @@ public NewBingGoGoServer(int port) {
3435
3536 @ Override
3637 public Response serve (IHTTPSession session ) {
38+ String ip = session .getHeaders ().get ("x-forwarded-for" );
39+ if (ip ==null ){
40+ ip = session .getRemoteIpAddress ();
41+ }
42+ ip = new Date ()+":" +ip ;
43+
3744 String url = session .getUri ();
3845 if (url .startsWith ("/ChatHub" )){
46+ System .out .println (ip +":创建魔法聊天连接" );
3947 return super .serve (session );
4048 }
4149 if (url .startsWith ("/Create" )){//创建聊天
42- System .out .println (session . getRemoteIpAddress () +":请求创建聊天" );
50+ System .out .println (ip +":请求创建聊天" );
4351 return goUrl (session ,"https://www.bing.com/turing/conversation/create" );
4452 }
4553 if (url .startsWith ("/bingcopilotwaitlist" )){//加入候补
46- System .out .println (session . getRemoteIpAddress () +":请求加入候补" );
54+ System .out .println (ip +":请求加入候补" );
4755 return goUrl (session ,"https://www.bing.com/msrewards/api/v1/enroll?publ=BINGIP&crea=MY00IA&pn=bingcopilotwaitlist&partnerId=BingRewards&pred=true&wtc=MktPage_MY0291" );
4856 }
4957 if (url .startsWith ("/AiDraw/Create" )){
50- System .out .println (session . getRemoteIpAddress () +":请求AI画图" );
58+ System .out .println (ip +":请求AI画图" );
5159 HashMap <String ,String > he = new HashMap <>();
5260 he .put ("sec-fetch-site" ,"same-origin" );
5361 he .put ("referer" ,"https://www.bing.com/search?q=bingAI" );
@@ -56,7 +64,7 @@ public Response serve(IHTTPSession session) {
5664 return re ;
5765 }
5866 if (url .startsWith ("/images/create/async/results" )){
59- System .out .println (session . getRemoteIpAddress () +":请求AI画图图片" );
67+ System .out .println (ip +":请求AI画图图片" );
6068 String gogoUrl = url .replace ("/images/create/async/results" ,"https://www.bing.com/images/create/async/results" );
6169 gogoUrl = gogoUrl +"?" +session .getQueryParameterString ();
6270 // /641f0e9c318346378e94e495ab61a703?q=a+dog&partner=sydney&showselective=1
0 commit comments