Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /MarkinHaus_ToolBoxV2 /toolboxv2 /utils /brodcast /server.py
| import json | |
| import socket | |
| import time | |
| from typing import Any | |
| def make_known(name: str, get_flag: bytes = b"R", port=44667) -> Any | None: | |
| server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) | |
| # Enable port reusage so we will be able to run multiple clients and servers on single (host, port). | |
| # Do not use socket.SO_REUSEADDR except you using linux(kernel<3.9): goto https://stackoverflow.com/questions/14388706/how-do-so-reuseaddr-and-so-reuseport-differ for more information. | |
| # For linux hosts all sockets that want to share the same address and port combination must belong to processes that share the same effective user ID! | |
| # So, on linux(kernel>=3.9) you have to run multiple servers and clients under one user to share the same (host, port). | |
| # Thanks to @stevenreddie | |
| server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
| # Enable broadcasting mode | |
| server.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
| message = get_flag + b":" + name.encode('utf-8') | |
| # Set a timeout so the socket does not block | |
| # indefinitely when trying to receive data. | |
| server.settimeout(0.2) | |
| # server.bind(("", port)) | |
| # server.send(message) | |
| server.sendto(message, ("255.255.255.255", port)) | |
| print("message sent!", flush=True) | |
| time.sleep(4) | |
| data = b'{"host":"","port":0}' | |
| try: | |
| data = server.recv(1024) | |
| print(f"data received! {data.decode()}", flush=True) | |
| except: | |
| pass | |
| finally: | |
| server.close() | |
| return json.loads(data.decode()) | |
| # ssh -L 8221:localhost:9001 -L 8222:localhost:9000 name@ip -N | |
Xet Storage Details
- Size:
- 1.63 kB
- Xet hash:
- 01ea8aa9378ab9608d1df3dfe925e2c882d70cbad7cbeeb8b23def8c9ec0eff1
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.