Преглед на файлове

script: add tor-test util

darkfi преди 2 години
родител
ревизия
f6786f5b0c
променени са 4 файла, в които са добавени 32 реда и са изтрити 8 реда
  1. 1 2
      script/lilith_spawns.py
  2. 1 3
      script/node_get-info.py
  3. 1 3
      script/nodetool.py
  4. 29 0
      script/tor-test.py

+ 1 - 2
script/lilith_spawns.py

@@ -1,3 +1,4 @@
+#!/usr/bin/python
 # This file is part of DarkFi (https://dark.fi)
 #
 # Copyright (C) 2020-2024 Dyne.org foundation
@@ -16,7 +17,6 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 import asyncio, json, random, sys, time
 
-
 class JsonRpc:
 
     async def start(self, server, port):
@@ -105,5 +105,4 @@ async def main(argv):
                 print(f"    {host}")
     await rpc.stop()
 
-
 asyncio.run(main(sys.argv))

+ 1 - 3
script/node_get-info.py

@@ -1,3 +1,4 @@
+#!/usr/bin/python
 # This file is part of DarkFi (https://dark.fi)
 #
 # Copyright (C) 2020-2024 Dyne.org foundation
@@ -16,7 +17,6 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 import asyncio, json, random, sys, time
 
-
 class JsonRpc:
 
     async def start(self, server, port):
@@ -71,7 +71,6 @@ class JsonRpc:
     async def dnet_subscribe_events(self):
         return await self._subscribe("dnet.subscribe_events", [])
 
-
 async def main(argv):
     rpc = JsonRpc()
     while True:
@@ -121,5 +120,4 @@ async def main(argv):
 
     await rpc.stop()
 
-
 asyncio.run(main(sys.argv))

+ 1 - 3
script/nodetool.py

@@ -1,3 +1,4 @@
+#!/usr/bin/python
 # This file is part of DarkFi (https://dark.fi)
 #
 # Copyright (C) 2020-2024 Dyne.org foundation
@@ -16,7 +17,6 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 import asyncio, json, random, sys, time
 
-
 class JsonRpc:
 
     async def start(self, server, port):
@@ -71,7 +71,6 @@ class JsonRpc:
     async def dnet_subscribe_events(self):
         return await self._subscribe("dnet.subscribe_events", [])
 
-
 async def main(argv):
     rpc = JsonRpc()
     while True:
@@ -130,5 +129,4 @@ async def main(argv):
     await rpc.dnet_switch(False)
     await rpc.stop()
 
-
 asyncio.run(main(sys.argv))

+ 29 - 0
script/tor-test.py

@@ -0,0 +1,29 @@
+#!/usr/bin/python
+# This file is part of DarkFi (https://dark.fi)
+#
+# Copyright (C) 2020-2024 Dyne.org foundation
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+# Tests if your local tor node is working
+
+# pip install pysocks
+import socks
+import socket
+socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 9050)
+socket.socket = socks.socksocket
+import requests
+response = requests.get("https://myip.wtf/text")
+print(response.content)
+