MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / builtin

Function builtin

stream/main.py:88–129  ·  view source on GitHub ↗
(
    queue: Optional[Any] = None, port: Optional[int] = None, proxy: Optional[str] = None
)

Source from the content-addressed store, hash-verified

86
87
88async def builtin(
89 queue: Optional[Any] = None, port: Optional[int] = None, proxy: Optional[str] = None
90) -> None:
91 # Set up logging with GridFormatter for consistent output
92 set_source("PROXY")
93
94 console_handler = logging.StreamHandler(sys.stderr)
95 console_handler.setFormatter(GridFormatter(show_tree=True, colorize=True))
96 console_handler.setLevel(logging.INFO)
97
98 # Configure proxy_server logger specifically (not root)
99 logger = logging.getLogger("proxy_server")
100 logger.handlers.clear() # Remove any existing handlers
101 logger.addHandler(console_handler)
102 logger.setLevel(logging.INFO)
103 logger.propagate = False # Prevent double logging
104
105 # Create certs directory
106 cert_dir = Path("certs")
107 cert_dir.mkdir(exist_ok=True)
108
109 if port is None:
110 port = 3120
111
112 # Create and start the proxy server
113 proxy_server = ProxyServer(
114 host="127.0.0.1",
115 port=port,
116 intercept_domains=["*.google.com"],
117 upstream_proxy=proxy,
118 queue=queue,
119 )
120
121 try:
122 await proxy_server.start()
123 except KeyboardInterrupt:
124 logger.info("Shutting down proxy server")
125 except asyncio.CancelledError:
126 raise
127 except Exception as e:
128 logger.error(f"Error starting proxy server: {e}", exc_info=True)
129 sys.exit(1)
130
131
132if __name__ == "__main__":

Calls 7

startMethod · 0.95
set_sourceFunction · 0.90
GridFormatterClass · 0.90
ProxyServerClass · 0.90
infoMethod · 0.80
errorMethod · 0.80
clearMethod · 0.45