Skip to content

Commit

Permalink
Enhance README and Proxy functionality
Browse files Browse the repository at this point in the history
- Added center-aligned logo to README
- Included build, test, and Go report badges in README
- Updated NewProxy function to support optional SSL configuration based on source database port
- Adjusted proxy initialization to log SSL settings based on port value
  • Loading branch information
mattmattox committed Nov 17, 2024
2 parents 7bd3eaa + d4b1f2c commit d6dc14a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<p align="center">
<img src="https://cdn.support.tools/go-sql-proxy/go-sql-proxy-no-bg.png">
</p>

# Go-SQL-Proxy

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.

[![Build, Test and Publish](https://github.com/SupportTools/go-sql-proxy/actions/workflows/build-and-publish.yml/badge.svg?branch=main)](https://github.com/SupportTools/go-sql-proxy/actions/workflows/build-and-publish.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/SupportTools/go-sql-proxy)](https://goreportcard.com/report/github.com/SupportTools/go-sql-proxy)
[![Go Reference](https://pkg.go.dev/badge/github.com/SupportTools/go-sql-proxy.svg)](https://pkg.go.dev/github.com/SupportTools/go-sql-proxy)

## Project Structure

The project is structured as follows:
Expand Down
11 changes: 10 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel() // Ensure cancel is called to release resources if main exits before signal

p := proxy.NewProxy(ctx, config.CFG.SourceDatabaseServer, config.CFG.SourceDatabasePort)
var useSSL bool
if config.CFG.SourceDatabasePort == 3306 {
logger.Println("SourceDatabasePort is 3306, disabling SSL")
useSSL = false
} else {
logger.Println("Enabling SSL for non-default port")
useSSL = true
}

p := proxy.NewProxy(ctx, config.CFG.SourceDatabaseServer, config.CFG.SourceDatabasePort, useSSL)
p.EnableDecoding = true

var wg sync.WaitGroup
Expand Down
1 change: 1 addition & 0 deletions pkg/models/Proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
type Proxy struct {
Host string
Port int
UseSSL bool
ConnectionID uint64
EnableDecoding bool
Ctx context.Context
Expand Down
11 changes: 6 additions & 5 deletions pkg/proxy/NewProxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"github.com/supporttools/go-sql-proxy/pkg/models"
)

// NewProxy creates a new instance of the Proxy server.
func NewProxy(ctx context.Context, host string, port int) *models.Proxy {
// NewProxy creates a new instance of the Proxy server with optional SSL configuration.
func NewProxy(ctx context.Context, host string, port int, useSSL bool) *models.Proxy {
return &models.Proxy{
Host: host,
Port: port,
Ctx: ctx,
Host: host,
Port: port,
UseSSL: useSSL,
Ctx: ctx,
}
}

0 comments on commit d6dc14a

Please sign in to comment.