An open API service indexing awesome lists of open source software.

https://github.com/yeong-hwan/local-proxy

Local proxy program can bypass and image blocking
https://github.com/yeong-hwan/local-proxy

bypass image-block proxy socket-programming

Last synced: over 1 year ago
JSON representation

Local proxy program can bypass and image blocking

Awesome Lists containing this project

README

          

# local-proxy

## Flow chart by Psuedo code


drawing

## How to run
Check detail proxy setting [here](#mac-proxy-server-setup)

```zsh
cd src
python3 proxy.py 8080
```

## How it works
**Parsing for get “User-Agent” data**
```python
request_data_dict = {}

for line in request_data.decode().splitlines():
try:
title, content = line.split(": ")
request_data_dict[title] = content
except:
pass

response_user_agent = request_data_dict['User-Agent']
end_index = response_user_agent.find(")")
cleaned_user_agent = response_user_agent[:end_index+1].replace("User-Agent: ", "")
```


**Redirection to “mnet.Yonsei.ac.kr” when URL has “korea”**
```python
# Connect to the destination server
server_socket = None
response_data = None

try:
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if url_filter == "O":
destination_host = "mnet.yonsei.ac.kr"
server_socket.connect((destination_host, 80))
except Exception as e:
print("\nServer socket error: " + str(e))

server_socket.sendall(request_data)
```


**Image Filtering**
Log response through proxy
It logs also http status, content-type, content-length and send response_data to client
But It don’t send response_data when drop image

```python
# Print log for the received response
print(f"[CLI <== PRX --- SRV]")

if image_filter == "O":
if response_content.startswith("image"):
print(f" > 404 Not Found")
else:
print(f" > {cleaned_status}")
print(f" > {response_content} {response_bytes}bytes")
client_socket.sendall(response_data)
else:
print(f" > {cleaned_status}")
print(f" > {response_content} {response_bytes}bytes")

# Forward the modified response to the client
client_socket.sendall(response_data)
```

## Snapshots

### Mac proxy server setup


drawing

### Image filtering
**Image filtering at test page**


drawing

### Redirection
**Redirection from Korea univ page to Yonsei univ page**


drawing

**Image filtering with Redirection**


drawing

## Environment
OS: Mac Sonoma
Language: Python(3.8.5)