Merge branch 'main' of git.mosad.xyz:localhorst/LocationHub
This commit is contained in:
		
							
								
								
									
										88
									
								
								server/scripts/wigle-dummy.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								server/scripts/wigle-dummy.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,88 @@ | ||||
| #!/usr/bin/env python3 | ||||
| # -*- coding: utf-8 -*- | ||||
| """ Author:                     Hendrik Schutter, mail@hendrikschutter.com | ||||
| """ | ||||
|  | ||||
| import requests | ||||
| import os | ||||
| import json | ||||
| import argparse | ||||
| import random | ||||
| import http.server | ||||
| import json | ||||
| from urllib.parse import urlparse, parse_qs | ||||
|  | ||||
| port = 8000 | ||||
|  | ||||
| def generateDummyResponse(netid): | ||||
|     response_payload = { | ||||
|         "success": True, | ||||
|         "totalResults": 1, | ||||
|         "first": 0, | ||||
|         "last": 0, | ||||
|         "resultCount": 1, | ||||
|         "results": [ | ||||
|             { | ||||
|                 "trilat": random.uniform(-90, 90), | ||||
|                 "trilong": random.uniform(-180, 180), | ||||
|                 "ssid": "Wifi-Name", | ||||
|                 "qos": 0, | ||||
|                 "transid": "string", | ||||
|                 "firsttime": "2025-01-02T16:48:28.368Z", | ||||
|                 "lasttime": "2025-01-02T16:48:28.368Z", | ||||
|                 "lastupdt": "2025-01-02T16:48:28.368Z", | ||||
|                 "netid": netid, | ||||
|                 "name": "string", | ||||
|                 "type": "string", | ||||
|                 "comment": "string", | ||||
|                 "wep": "string", | ||||
|                 "bcninterval": 0, | ||||
|                 "freenet": "string", | ||||
|                 "dhcp": "string", | ||||
|                 "paynet": "string", | ||||
|                 "userfound": False, | ||||
|                 "channel": 0, | ||||
|                 "rcois": "string", | ||||
|                 "encryption": "none", | ||||
|                 "country": "string", | ||||
|                 "region": "string", | ||||
|                 "road": "string", | ||||
|                 "city": "string", | ||||
|                 "housenumber": "string", | ||||
|                 "postalcode": "string", | ||||
|             } | ||||
|         ], | ||||
|         "searchAfter": "string", | ||||
|         "search_after": 0, | ||||
|     } | ||||
|  | ||||
|     return response_payload | ||||
|  | ||||
| class SimpleHTTPRequestHandler(http.server.BaseHTTPRequestHandler): | ||||
|     def do_GET(self): | ||||
|         # Parse the URL and query parameters | ||||
|         parsed_url = urlparse(self.path) | ||||
|         if parsed_url.path == "/api/v2/network/search": | ||||
|             query_params = parse_qs(parsed_url.query) | ||||
|             netid = query_params.get("netid", [""])[0] | ||||
|  | ||||
|             # Send response headers | ||||
|             self.send_response(200) | ||||
|             self.send_header("Content-Type", "application/json") | ||||
|             self.end_headers() | ||||
|  | ||||
|             # Send the JSON response | ||||
|             self.wfile.write(json.dumps(generateDummyResponse(netid)).encode("utf-8")) | ||||
|         else: | ||||
|             # Handle 404 Not Found | ||||
|             self.send_response(404) | ||||
|             self.end_headers() | ||||
|             self.wfile.write(b"Not Found") | ||||
|  | ||||
| def main(): | ||||
|     server = http.server.HTTPServer(("127.0.0.1", port), SimpleHTTPRequestHandler) | ||||
|     print(f"Server running on http://127.0.0.1:{port}/api/v2/network/search'...") | ||||
|     server.serve_forever() | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     main() | ||||
		Reference in New Issue
	
	Block a user