add get public v6
This commit is contained in:
		
							parent
							
								
									a5bb3e3f59
								
							
						
					
					
						commit
						aebdf3b66e
					
				
							
								
								
									
										11
									
								
								Utils.py
								
								
								
								
							
							
						
						
									
										11
									
								
								Utils.py
								
								
								
								
							| 
						 | 
				
			
			@ -190,6 +190,17 @@ def get_public_ipv4() -> str:
 | 
			
		|||
            pass  # we could be offline, in a local game, so no point in erroring out
 | 
			
		||||
    return ip
 | 
			
		||||
 | 
			
		||||
def get_public_ipv6() -> str:
 | 
			
		||||
    import socket
 | 
			
		||||
    import urllib.request
 | 
			
		||||
    import logging
 | 
			
		||||
    ip = socket.gethostbyname(socket.gethostname())
 | 
			
		||||
    try:
 | 
			
		||||
        ip = urllib.request.urlopen('https://v6.ident.me').read().decode('utf8').strip()
 | 
			
		||||
    except Exception as e:
 | 
			
		||||
        logging.exception(e)
 | 
			
		||||
        pass  # we could be offline, in a local game, so no point in erroring out
 | 
			
		||||
    return ip
 | 
			
		||||
 | 
			
		||||
def get_options() -> dict:
 | 
			
		||||
    if not hasattr(get_options, "options"):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue