Skip to content

Commit dd7cc31

Browse files
committed
Updating Readme and adding snyk scanning
1 parent f46268a commit dd7cc31

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ jobs:
1313
- name: Checkout repository
1414
uses: actions/checkout@v2
1515

16+
- name: Run Snyk to check for vulnerabilities
17+
uses: snyk/actions/golang@master
18+
env:
19+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
20+
with:
21+
args: --sarif-file-output=snyk.sarif
22+
23+
- name: Upload result to GitHub Code Scanning
24+
uses: github/codeql-action/upload-sarif@v2
25+
with:
26+
sarif_file: snyk.sarif
27+
1628
- name: Docker build and push
1729
run: |
1830
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,53 @@
1-
# go-sql-proxy
1+
# Go-SQL-Proxy
2+
3+
This project implements a SQL proxy server in Golang that acts as an intermediary between a client and a MySQL server. The proxy server can handle protocol decoding and data transfer while measuring and updating metrics for monitoring purposes.
4+
5+
## Project Structure
6+
7+
The project is structured as follows:
8+
9+
- **pkg/**
10+
- **config/**
11+
- `config.go`: Contains the configuration settings and loads them from environment variables.
12+
- **logging/**
13+
- `logging.go`: Handles setting up and configuring the logger using Logrus.
14+
- **metrics/**
15+
- `metrics.go`: Implements metrics collection and exposes Prometheus metrics endpoints.
16+
- **health/**
17+
- `health.go`: Handles health check endpoints for database connectivity.
18+
- **protocol/**
19+
- `flags.go`: Defines MySQL capability flags used in the protocol.
20+
- `math.go`: Contains utility functions for mathematical operations.
21+
- `protocol.go`: Implements decoding and encoding of MySQL protocol packets.
22+
- **proxy/**
23+
- `NewConnection.go`: Creates a new proxy connection to the target MySQL server.
24+
- `NewProxy.go`: Creates a new instance of the Proxy server.
25+
- `HandleConnection.go`: Manages data transfer and protocol decoding for a connection.
26+
- `proxyHandle.go`: Handles a new connection request in a goroutine.
27+
- `transferData.go`: Handles data transfer between client and server while measuring latency.
28+
- `StartProxy.go`: Starts the proxy server and accepts incoming connections.
29+
- `EnableDecoding.go`: Enables protocol decoding for the proxy.
30+
- `handleProtocolDecoding.go`: Decodes the MySQL protocol handshake.
31+
- **models/**
32+
- `Proxy.go`: Defines the structure for the proxy server configuration and state.
33+
- `Connection.go`: Represents a connection to a MySQL server.
34+
- `main.go`: Main entry point of the proxy server application.
35+
36+
## Running the Server
37+
38+
To start the Go-SQL-Proxy server, the main entry point is `main.go`. The server can be started by running this file with the necessary environment variables configured to set up the proxy settings.
39+
40+
To run the server, execute the following command:
41+
42+
```bash
43+
go run main.go
44+
```
45+
46+
You can customize the server configurations by setting the environment variables as defined in `pkg/config/config.go`.
47+
48+
## Note
49+
50+
- This implementation serves as a basic demonstration of a SQL proxy server and may require additional features for production use.
51+
- Ensure proper configuration of database access and proxy settings before running the server in a production environment.
52+
53+
Feel free to explore and extend this project for your specific use case or requirements!
249 KB
Loading

0 commit comments

Comments
 (0)