Normal
This commit is contained in:
parent
54a9a540a7
commit
3f035ee580
4
src/sshsurf/__init__.py
Normal file
4
src/sshsurf/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from .client import sshClient
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = "0.0.1a"
|
BIN
src/sshsurf/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
src/sshsurf/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
src/sshsurf/__pycache__/client.cpython-311.pyc
Normal file
BIN
src/sshsurf/__pycache__/client.cpython-311.pyc
Normal file
Binary file not shown.
120
src/sshsurf/client.py
Normal file
120
src/sshsurf/client.py
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
import aiohttp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class sshClient:
|
||||||
|
def __init__(self, apikey: str):
|
||||||
|
self.sshheader = {'x-ssh-auth': apikey}
|
||||||
|
self.base_url = "https://api.ssh.surf"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async def hello(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/hello') as resp:
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def name(self):
|
||||||
|
# its kinda pointless to make this but its alrigh
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/name'):
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
async def start(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/start') as resp:
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def stop(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/stop'):
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def restart(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/restart') as resp:
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def info(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/info'):
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
async def stats(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/stats') as resp:
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def time(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/time'):
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async def rootpass(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/rootpass') as resp:
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def newkey(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/new-key'):
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async def keytime(self):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/key-time') as resp:
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def license(self):
|
||||||
|
# its kinda pointless to make this but its alrigh
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.get(self.base_url + '/license'):
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def exec(self, pwd: str, cmd: str):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.post(self.base_url + '/exec', json={"pwd": pwd, "cmd": cmd}) as resp:
|
||||||
|
result = await resp.json()
|
||||||
|
return result
|
||||||
|
|
||||||
|
async def notify(self, message: str):
|
||||||
|
async with aiohttp.ClientSession(headers=self.sshheader) as ses:
|
||||||
|
async with ses.post(self.base_url + '/notify', json={'message': message}) as resp:
|
||||||
|
result = await resp.json()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("https://youtu.be/qZWCxNDRVPc")
|
Loading…
Reference in New Issue
Block a user