Antonio Cheong commited on
Commit
6d7294b
·
1 Parent(s): 6bdffa2

randomized microsoft IP

Browse files
Files changed (1) hide show
  1. src/EdgeGPT.py +12 -5
src/EdgeGPT.py CHANGED
@@ -5,6 +5,7 @@ import argparse
5
  import asyncio
6
  import json
7
  import os
 
8
  import sys
9
  from typing import Generator
10
  from typing import Optional
@@ -14,6 +15,12 @@ import websockets.client as websockets
14
 
15
  DELIMITER = "\x1e"
16
 
 
 
 
 
 
 
17
  HEADERS = {
18
  "user-agent": (
19
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
@@ -23,7 +30,7 @@ HEADERS = {
23
  "referer": "https://www.bing.com/",
24
  "sec-ch-ua": '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
25
  "sec-ch-ua-platform": "Windows",
26
- "x-forwarded-for": "8.8.8.8",
27
  }
28
 
29
 
@@ -103,7 +110,7 @@ class Conversation:
103
  Conversation API
104
  """
105
 
106
- def __init__(self, cookiePath: str = '') -> None:
107
  self.struct: dict = {
108
  "conversationId": None,
109
  "clientId": None,
@@ -111,10 +118,10 @@ class Conversation:
111
  "result": {"value": "Success", "message": None},
112
  }
113
  self.session = tls_client.Session(client_identifier="chrome_108")
114
- if cookiePath == '':
115
  f = open(os.environ.get("COOKIE_FILE"), encoding="utf-8").read()
116
  else:
117
- f = open(cookiePath, encoding='utf8').read()
118
  cookie_file = json.loads(f)
119
  for cookie in cookie_file:
120
  self.session.cookies.set(cookie["name"], cookie["value"])
@@ -213,7 +220,7 @@ class Chatbot:
213
  Combines everything to make it seamless
214
  """
215
 
216
- def __init__(self, cookiePath: str = '') -> None:
217
  self.chat_hub: ChatHub = ChatHub(Conversation(cookiePath))
218
 
219
  async def ask(self, prompt: str) -> dict:
 
5
  import asyncio
6
  import json
7
  import os
8
+ import random
9
  import sys
10
  from typing import Generator
11
  from typing import Optional
 
15
 
16
  DELIMITER = "\x1e"
17
 
18
+ # Generate random IP between range 13.104.0.0/14
19
+ FORWARDED_IP = (
20
+ f"13.{random.randint(104, 107)}.{random.randint(0, 255)}.{random.randint(0, 255)}"
21
+ )
22
+
23
+
24
  HEADERS = {
25
  "user-agent": (
26
  "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
 
30
  "referer": "https://www.bing.com/",
31
  "sec-ch-ua": '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
32
  "sec-ch-ua-platform": "Windows",
33
+ "x-forwarded-for": FORWARDED_IP,
34
  }
35
 
36
 
 
110
  Conversation API
111
  """
112
 
113
+ def __init__(self, cookiePath: str = "") -> None:
114
  self.struct: dict = {
115
  "conversationId": None,
116
  "clientId": None,
 
118
  "result": {"value": "Success", "message": None},
119
  }
120
  self.session = tls_client.Session(client_identifier="chrome_108")
121
+ if cookiePath == "":
122
  f = open(os.environ.get("COOKIE_FILE"), encoding="utf-8").read()
123
  else:
124
+ f = open(cookiePath, encoding="utf8").read()
125
  cookie_file = json.loads(f)
126
  for cookie in cookie_file:
127
  self.session.cookies.set(cookie["name"], cookie["value"])
 
220
  Combines everything to make it seamless
221
  """
222
 
223
+ def __init__(self, cookiePath: str = "") -> None:
224
  self.chat_hub: ChatHub = ChatHub(Conversation(cookiePath))
225
 
226
  async def ask(self, prompt: str) -> dict: