mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
parent
7356987e6e
commit
47a9f99523
1 changed files with 3 additions and 11 deletions
|
@ -19,14 +19,6 @@ else:
|
||||||
import socketserver as SocketServer
|
import socketserver as SocketServer
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
|
|
||||||
# Check to see if IPv6 is enabled in the kernel
|
|
||||||
HAS_IPV6 = True
|
|
||||||
try:
|
|
||||||
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
|
||||||
s.close()
|
|
||||||
except:
|
|
||||||
HAS_IPV6 = False
|
|
||||||
|
|
||||||
# Disable CLI web browsers
|
# Disable CLI web browsers
|
||||||
term = os.environ.pop('TERM', None)
|
term = os.environ.pop('TERM', None)
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
@ -34,7 +26,7 @@ if term:
|
||||||
os.environ['TERM'] = term
|
os.environ['TERM'] = term
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import re, socket, cgi, select, time, glob, random, string, binascii
|
import re, cgi, select, time, glob, random, string, binascii
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -466,7 +458,7 @@ class FishConfigTCPServer(SocketServer.TCPServer):
|
||||||
"""TCPServer that only accepts connections from localhost (IPv4/IPv6)."""
|
"""TCPServer that only accepts connections from localhost (IPv4/IPv6)."""
|
||||||
WHITELIST = set(['::1', '::ffff:127.0.0.1', '127.0.0.1'])
|
WHITELIST = set(['::1', '::ffff:127.0.0.1', '127.0.0.1'])
|
||||||
|
|
||||||
address_family = socket.AF_INET6 if HAS_IPV6 else socket.AF_INET
|
address_family = socket.AF_INET6 if socket.has_ipv6 else socket.AF_INET
|
||||||
|
|
||||||
def verify_request(self, request, client_address):
|
def verify_request(self, request, client_address):
|
||||||
return client_address[0] in FishConfigTCPServer.WHITELIST
|
return client_address[0] in FishConfigTCPServer.WHITELIST
|
||||||
|
@ -968,7 +960,7 @@ authkey = binascii.b2a_hex(os.urandom(16)).decode('ascii')
|
||||||
|
|
||||||
# Try to find a suitable port
|
# Try to find a suitable port
|
||||||
PORT = 8000
|
PORT = 8000
|
||||||
HOST = "::" if HAS_IPV6 else "localhost"
|
HOST = "::" if socket.has_ipv6 else "localhost"
|
||||||
while PORT <= 9000:
|
while PORT <= 9000:
|
||||||
try:
|
try:
|
||||||
Handler = FishConfigHTTPRequestHandler
|
Handler = FishConfigHTTPRequestHandler
|
||||||
|
|
Loading…
Reference in a new issue