{"id":22458079,"url":"https://github.com/yeong-hwan/local-proxy","last_synced_at":"2025-03-27T13:44:30.354Z","repository":{"id":224406400,"uuid":"763178345","full_name":"yeong-hwan/local-proxy","owner":"yeong-hwan","description":"Local proxy program can bypass and image blocking","archived":false,"fork":false,"pushed_at":"2024-02-28T08:52:36.000Z","size":40009,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T18:13:29.356Z","etag":null,"topics":["bypass","image-block","proxy","socket-programming"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yeong-hwan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-25T18:55:10.000Z","updated_at":"2024-02-28T07:28:11.000Z","dependencies_parsed_at":"2024-12-06T08:20:49.091Z","dependency_job_id":null,"html_url":"https://github.com/yeong-hwan/local-proxy","commit_stats":null,"previous_names":["yeong-hwan/local-proxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeong-hwan%2Flocal-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeong-hwan%2Flocal-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeong-hwan%2Flocal-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeong-hwan%2Flocal-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeong-hwan","download_url":"https://codeload.github.com/yeong-hwan/local-proxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245858561,"owners_count":20684054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bypass","image-block","proxy","socket-programming"],"created_at":"2024-12-06T08:10:42.267Z","updated_at":"2025-03-27T13:44:30.310Z","avatar_url":"https://github.com/yeong-hwan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# local-proxy\n\n## Flow chart by Psuedo code\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"imgs/psuedo_code.png\" alt=\"drawing\" width=700\"/\u003e\n\u003c/div\u003e\n\n## How to run\nCheck detail proxy setting \u003cU\u003e[here](#mac-proxy-server-setup)\u003c/U\u003e\n\n```zsh\ncd src\npython3 proxy.py 8080\n```\n\n## How it works\n**Parsing for get “User-Agent” data**  \n```python\nrequest_data_dict = {}\n\nfor line in request_data.decode().splitlines():\n    try:\n        title, content = line.split(\": \")\n        request_data_dict[title] = content\n    except:\n        pass\n\nresponse_user_agent = request_data_dict['User-Agent']\nend_index = response_user_agent.find(\")\")\ncleaned_user_agent = response_user_agent[:end_index+1].replace(\"User-Agent: \", \"\")\n```\n\n\u003cbr/\u003e\n\n**Redirection to “mnet.Yonsei.ac.kr” when URL has “korea”**\n```python\n# Connect to the destination server\nserver_socket = None\nresponse_data = None\n\ntry: \n    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n    if url_filter == \"O\":\n        destination_host = \"mnet.yonsei.ac.kr\"\n    server_socket.connect((destination_host,  80))\nexcept Exception as e:\n    print(\"\\nServer socket error: \" + str(e))\n    \n\nserver_socket.sendall(request_data)\n```\n\n\u003cbr/\u003e\n\n**Image Filtering**  \nLog response through proxy  \nIt logs also http status, content-type, content-length and send response_data to client  \n\u003cU\u003eBut It don’t send response_data when drop image\u003c/U\u003e\n\n```python\n# Print log for the received response\nprint(f\"[CLI \u003c== PRX --- SRV]\")\n\nif image_filter == \"O\":\n    if response_content.startswith(\"image\"):\n        print(f\" \u003e 404 Not Found\")\n    else:\n        print(f\" \u003e {cleaned_status}\")\n        print(f\" \u003e {response_content} {response_bytes}bytes\")\n        client_socket.sendall(response_data)\nelse:\n    print(f\" \u003e {cleaned_status}\")\n    print(f\" \u003e {response_content} {response_bytes}bytes\")\n\n    # Forward the modified response to the client\n    client_socket.sendall(response_data)\n```\n\n## Snapshots\n\n### Mac proxy server setup\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"imgs/proxy_setup.png\" alt=\"drawing\" width=500\"/\u003e\n\u003c/div\u003e\n\n### Image filtering\n**Image filtering at test page**\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"imgs/image_filtering.png\" alt=\"drawing\" width=500\"/\u003e\n\u003c/div\u003e\n\n### Redirection\n**Redirection from Korea univ page to Yonsei univ page**\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"imgs/test.gif\" alt=\"drawing\" width=700\"/\u003e\n\u003c/div\u003e\n\n**Image filtering with Redirection**\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"imgs/redirection_with_filtering.png\" alt=\"drawing\" width=500\"/\u003e\n\u003c/div\u003e\n\n## Environment\nOS: Mac Sonoma  \nLanguage: Python(3.8.5)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeong-hwan%2Flocal-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeong-hwan%2Flocal-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeong-hwan%2Flocal-proxy/lists"}