Skip to content

Commit dea0ec8

Browse files
author
yigitkonur
committed
first commit
0 parents  commit dea0ec8

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
Go-Proxy-Server is a high-performance, fast, and efficient proxy server fully written in Go. It serves as an alternative to traditional proxy solutions like Squid, offering modern features and superior performance thanks to Go's concurrency model.
2+
3+
## Features
4+
5+
- **High Performance**: Leveraging Go's goroutines for efficient handling of multiple connections concurrently.
6+
- **HTTP/1.1 and HTTP/2 Support**: Handles both HTTP/1.1 and HTTP/2 protocols.
7+
- **HTTPS Proxying**: Supports tunneling for HTTPS connections.
8+
- **Basic Authentication and Access Control**: (Planned for future development)
9+
- **Logging**: Structured logging using Uber's `zap` library.
10+
- **Monitoring**: Integrates with Prometheus for metrics collection.
11+
- **Configuration Management**: Uses `viper` for flexible configuration.
12+
13+
## Requirements
14+
15+
- Go 1.18 or higher
16+
- Access to a Unix-like environment (Linux, macOS)
17+
18+
## Installation
19+
20+
1. **Clone the repository:**
21+
22+
```bash
23+
git clone https://github.com/yourusername/go-proxy-server.git
24+
cd go-proxy-server
25+
```
26+
27+
2. **Initialize the Go module:**
28+
29+
```bash
30+
go mod init proxy-server
31+
```
32+
33+
3. **Download dependencies:**
34+
35+
```bash
36+
go get github.com/spf13/viper
37+
go get go.uber.org/zap
38+
go get github.com/prometheus/client_golang/prometheus/promhttp
39+
go get github.com/stretchr/testify/assert
40+
go get github.com/valyala/fasthttp
41+
```
42+
43+
4. **Build the project:**
44+
45+
```bash
46+
cd cmd/proxy
47+
go build -o proxy-server
48+
```
49+
50+
## Usage
51+
52+
1. **Create a configuration file (`config.yaml`) in the root directory:**
53+
54+
```yaml
55+
ServerAddress: ":8080"
56+
MaxConnections: 10000
57+
LogLevel: "info"
58+
```
59+
60+
2. **Run the proxy server:**
61+
62+
```bash
63+
./proxy-server
64+
```
65+
66+
3. **Test the proxy server using `curl`:**
67+
68+
```bash
69+
curl -x 127.0.0.1:8080 http://ifconfig.io
70+
curl -x 127.0.0.1:8080 https://ifconfig.io
71+
```
72+
73+
## Project Structure
74+
75+
```plaintext
76+
proxy-server/
77+
├── cmd/
78+
│ └── proxy/
79+
│ └── main.go
80+
├── config.yaml
81+
├── go.mod
82+
├── go.sum
83+
├── pkg/
84+
│ ├── config/
85+
│ │ └── config.go
86+
│ ├── handler/
87+
│ │ └── handler.go
88+
│ ├── log/
89+
│ │ └── log.go
90+
│ ├── metrics/
91+
│ │ └── metrics.go
92+
│ ├── pool/
93+
│ │ └── pool.go
94+
│ └── proxy/
95+
│ └── proxy.go
96+
└── test/
97+
└── proxy_test.go
98+
```
99+
100+
## Code Overview
101+
102+
- **cmd/proxy/main.go**: Entry point of the application. Loads configuration, sets up logging, initializes the proxy server, and handles graceful shutdown.
103+
- **pkg/config/config.go**: Handles loading and validating configuration using `viper`.
104+
- **pkg/handler/handler.go**: Contains the request handling logic for both HTTP and HTTPS requests.
105+
- **pkg/log/log.go**: Sets up structured logging using Uber's `zap` library.
106+
- **pkg/metrics/metrics.go**: Sets up Prometheus metrics for monitoring.
107+
- **pkg/pool/pool.go**: Implements a connection pool to reuse `fasthttp.Client` instances.
108+
- **pkg/proxy/proxy.go**: Initializes and starts the `fasthttp` server, and handles server shutdown.
109+
- **test/proxy_test.go**: Contains unit tests for the proxy server.
110+
111+
## Contributing
112+
113+
Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.
114+
115+
## License
116+
117+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
118+
119+
## Acknowledgements
120+
121+
- [fasthttp](https://github.com/valyala/fasthttp): High-performance HTTP package for Go.
122+
- [zap](https://github.com/uber-go/zap): High-performance logging library.
123+
- [viper](https://github.com/spf13/viper): Configuration management library.
124+
- [Prometheus](https://prometheus.io/): Monitoring and alerting toolkit.
125+
126+
# go-native-squid-proxy

0 commit comments

Comments
 (0)