Add support for private IP range 10.0.0.0-10.255.255.255 (#10)
This commit is contained in:
parent
874145f2a5
commit
23dac08e45
3 changed files with 7 additions and 6 deletions
4
dance.py
4
dance.py
|
@ -36,7 +36,7 @@ class PairingMethod(Enum):
|
||||||
|
|
||||||
|
|
||||||
REGEX_PAIRING_CODE = re.compile(r'^\d{6}$')
|
REGEX_PAIRING_CODE = re.compile(r'^\d{6}$')
|
||||||
REGEX_LOCAL_IP_ADDRESS = re.compile(r'^192\.168\.((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.)(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$')
|
REGEX_LOCAL_IP_ADDRESS = re.compile(r'^(192\.168|10.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]))\.((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.)(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$')
|
||||||
|
|
||||||
|
|
||||||
async def get_device_ids():
|
async def get_device_ids():
|
||||||
|
@ -249,7 +249,7 @@ def is_valid_pairing_method(val):
|
||||||
def get_host_ip():
|
def get_host_ip():
|
||||||
try:
|
try:
|
||||||
for ip in socket.gethostbyname_ex(socket.gethostname())[2]:
|
for ip in socket.gethostbyname_ex(socket.gethostname())[2]:
|
||||||
if ip.startswith('192.168'):
|
if ip.startswith('192.168') or ip.startswith('10.'):
|
||||||
return ip
|
return ip
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -149,6 +149,7 @@ class JoyDance:
|
||||||
''' Open a port on this machine so the console can connect to it '''
|
''' Open a port on this machine so the console can connect to it '''
|
||||||
try:
|
try:
|
||||||
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
conn.settimeout(10)
|
||||||
conn.bind(('0.0.0.0', self.host_port))
|
conn.bind(('0.0.0.0', self.host_port))
|
||||||
conn.listen(5)
|
conn.listen(5)
|
||||||
|
|
||||||
|
@ -382,7 +383,7 @@ class JoyDance:
|
||||||
if self.tls_certificate:
|
if self.tls_certificate:
|
||||||
ssl_context.load_verify_locations(cadata=self.tls_certificate)
|
ssl_context.load_verify_locations(cadata=self.tls_certificate)
|
||||||
|
|
||||||
if '192.168' in self.pairing_url:
|
if self.pairing_url.startswith('192.168.') or self.pairing_url.startswith('10.'):
|
||||||
if self.console_conn:
|
if self.console_conn:
|
||||||
server_hostname = self.console_conn.getpeername()[0]
|
server_hostname = self.console_conn.getpeername()[0]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -107,7 +107,7 @@ class PrivateIpAddress extends Component {
|
||||||
let console_ip_addr = props.console_ip_addr
|
let console_ip_addr = props.console_ip_addr
|
||||||
|
|
||||||
let hostname = window.location.hostname
|
let hostname = window.location.hostname
|
||||||
if (hostname.startsWith('192.168.')) {
|
if (hostname.startsWith('192.168.') || hostname.startsWith('10.')) {
|
||||||
host_ip_addr = hostname
|
host_ip_addr = hostname
|
||||||
lock_host = true
|
lock_host = true
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ class PrivateIpAddress extends Component {
|
||||||
`}
|
`}
|
||||||
|
|
||||||
${([PairingMethod.FAST, PairingMethod.OLD].indexOf(pairing_method) > -1 || (pairing_method == PairingMethod.DEFAULT && !state.lock_host)) && html`
|
${([PairingMethod.FAST, PairingMethod.OLD].indexOf(pairing_method) > -1 || (pairing_method == PairingMethod.DEFAULT && !state.lock_host)) && html`
|
||||||
<input required id="ipAddr" type="text" inputmode="decimal" size="15" maxlength="15" placeholder="192.168.x.x" pattern="^192\\.168\\.((\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.)(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$" value=${addr} onKeyPress=${this.onKeyPress} onChange="${this.onChange}" />
|
<input required id="ipAddr" type="text" inputmode="decimal" size="15" maxlength="15" placeholder="192.168.?/10.?" pattern="^(192\\.168|10.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]))\\.((\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.)(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$" value=${addr} onKeyPress=${this.onKeyPress} onChange="${this.onChange}" />
|
||||||
`}
|
`}
|
||||||
|
|
||||||
`
|
`
|
||||||
|
@ -385,7 +385,7 @@ class App extends Component {
|
||||||
const state = this.state
|
const state = this.state
|
||||||
const pairing_method = state.pairing_method
|
const pairing_method = state.pairing_method
|
||||||
let addr = pairing_method == PairingMethod.DEFAULT ? state.host_ip_addr : state.console_ip_addr
|
let addr = pairing_method == PairingMethod.DEFAULT ? state.host_ip_addr : state.console_ip_addr
|
||||||
if (!addr.match(/^192\.168\.((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.)(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/)) {
|
if (!addr.match(/^(192\.168|10.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]))\.((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.)(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/)) {
|
||||||
alert('ERROR: Invalid IP address!')
|
alert('ERROR: Invalid IP address!')
|
||||||
document.getElementById('ipAddr').focus()
|
document.getElementById('ipAddr').focus()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue