mirror of
https://github.com/openziti/zrok.git
synced 2025-07-05 17:00:40 +02:00
align Py SDK with permission model
This commit is contained in:
@ -12,14 +12,16 @@ import threading
|
||||
|
||||
exit_signal = threading.Event()
|
||||
|
||||
|
||||
def signal_handler(signum, frame):
|
||||
print("\nCtrl-C detected. Next connection will close server")
|
||||
exit_signal.set()
|
||||
|
||||
|
||||
class copyto:
|
||||
def handle(self, *args, **kwargs):
|
||||
root = zrok.environment.root.Load()
|
||||
|
||||
|
||||
try:
|
||||
shr = zrok.share.CreateShare(root=root, request=ShareRequest(
|
||||
BackendMode=zrok.model.TCP_TUNNEL_BACKEND_MODE,
|
||||
@ -48,7 +50,6 @@ class copyto:
|
||||
conn.sendall(data.encode('utf-8'))
|
||||
|
||||
print("Server stopped.")
|
||||
|
||||
|
||||
def loadData(self):
|
||||
if not os.isatty(sys.stdin.fileno()):
|
||||
@ -56,6 +57,7 @@ class copyto:
|
||||
else:
|
||||
raise Exception("'copyto' requires input from stdin; direct your paste buffer into stdin")
|
||||
|
||||
|
||||
def pastefrom(options):
|
||||
root = zrok.environment.root.Load()
|
||||
|
||||
@ -66,7 +68,7 @@ def pastefrom(options):
|
||||
except Exception as e:
|
||||
print("unable to create access", e)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def removeAccess():
|
||||
try:
|
||||
zrok.access.DeleteAccess(root, acc)
|
||||
@ -79,6 +81,7 @@ def pastefrom(options):
|
||||
data = client.recv(1024)
|
||||
print(data.decode('utf-8'))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers()
|
||||
|
Reference in New Issue
Block a user