Allow localhost as domain

master
Bob Mottram 2019-07-03 13:24:54 +01:00
parent e4189a0bbe
commit 5ff78f55a1
2 changed files with 12 additions and 6 deletions

View File

@ -285,8 +285,9 @@ def runDaemon(domain: str,port=80,https=True,fedList=[],useTor=False) -> None:
if len(domain)==0: if len(domain)==0:
domain='localhost' domain='localhost'
if '.' not in domain: if '.' not in domain:
print('Invalid domain: ' + domain) if domain != 'localhost':
return print('Invalid domain: ' + domain)
return
serverAddress = ('', port) serverAddress = ('', port)
httpd = ThreadingHTTPServer(serverAddress, PubServer) httpd = ThreadingHTTPServer(serverAddress, PubServer)

View File

@ -49,7 +49,7 @@ def str2bool(v):
raise argparse.ArgumentTypeError('Boolean value expected.') raise argparse.ArgumentTypeError('Boolean value expected.')
parser = argparse.ArgumentParser(description='ActivityPub Server') parser = argparse.ArgumentParser(description='ActivityPub Server')
parser.add_argument('-d','--domain', dest='domain', type=str,default=None, parser.add_argument('-d','--domain', dest='domain', type=str,default='localhost',
help='Domain name of the server') help='Domain name of the server')
parser.add_argument('-p','--port', dest='port', type=int,default=8085, parser.add_argument('-p','--port', dest='port', type=int,default=8085,
help='Port number to run on') help='Port number to run on')
@ -61,9 +61,9 @@ parser.add_argument('--postsraw', dest='postsraw', type=str,default=None,
help='Show raw json of posts for the given handle') help='Show raw json of posts for the given handle')
parser.add_argument('-f','--federate', nargs='+',dest='federationList', parser.add_argument('-f','--federate', nargs='+',dest='federationList',
help='Specify federation list separated by spaces') help='Specify federation list separated by spaces')
parser.add_argument("--https", type=str2bool, nargs='?', parser.add_argument("--http", type=str2bool, nargs='?',
const=True, default=False, const=True, default=False,
help="Use https") help="Use http only")
parser.add_argument("--tor", type=str2bool, nargs='?', parser.add_argument("--tor", type=str2bool, nargs='?',
const=True, default=False, const=True, default=False,
help="Route via Tor") help="Route via Tor")
@ -103,7 +103,9 @@ if not args.domain:
nickname='admin' nickname='admin'
domain=args.domain domain=args.domain
port=args.port port=args.port
https=args.https https=True
if args.http:
https=False
useTor=args.tor useTor=args.tor
baseDir=args.baseDir baseDir=args.baseDir
if baseDir.endswith('/'): if baseDir.endswith('/'):
@ -114,4 +116,7 @@ federationList=[]
if args.federationList: if args.federationList:
federationList=args.federationList.copy() federationList=args.federationList.copy()
if not os.path.isdir(baseDir+'/accounts/'+nickname+'@'+domain):
privateKeyPem,publicKeyPem,person,wfEndpoint=createPerson(baseDir,nickname,domain,port,https,True)
runDaemon(domain,port,https,federationList,useTor) runDaemon(domain,port,https,federationList,useTor)