Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xaionaro-go/grpcproxy
A simple gRPC server and client to (forward) proxy TCP/UDP connections
https://github.com/xaionaro-go/grpcproxy
client forward-proxy go golang grpc http network proxy server tcp tun tunnel udp
Last synced: 17 days ago
JSON representation
A simple gRPC server and client to (forward) proxy TCP/UDP connections
- Host: GitHub
- URL: https://github.com/xaionaro-go/grpcproxy
- Owner: xaionaro-go
- License: cc0-1.0
- Created: 2024-10-30T15:32:53.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2024-10-30T15:38:54.000Z (18 days ago)
- Last Synced: 2024-10-30T16:35:40.430Z (18 days ago)
- Topics: client, forward-proxy, go, golang, grpc, http, network, proxy, server, tcp, tun, tunnel, udp
- Language: Go
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About
[![Go Reference](https://godoc.org/github.com/xaionaro-go/grpcproxy?status.svg)](https://godoc.org/github.com/xaionaro-go/grpcproxy)
[![Go Report Card](https://goreportcard.com/badge/github.com/xaionaro-go/grpcproxy?branch=main)](https://goreportcard.com/report/github.com/xaionaro-go/grpcproxy)This is a gRPC server and a client that allows to proxy network connections via the server.
# How to use
## Server-side
Let's say you already have a gRPC server written in Go, something like this:
```go
grpcServer := grpc.NewServer()
myFancyService := myfancyservice.New()
myFancyService_grpc.RegisterMyFancyServiceServer(grpcServer, myFancyService)
```To add the proxy capability you just need to register the proxy service as well:
```go
import "github.com/xaionaro-go/grpcproxy/grpcproxyserver"
import "github.com/xaionaro-go/grpcproxy/protobuf/go/proxy_grpc"grpcServer := grpc.NewServer()
myFancyService := myfancyservice.New()
myfancyservice_grpc.RegisterMyFancyServiceServer(grpcServer, myFancyService)proxyServer := grpcproxyserver.New()
proxy_grpc.RegisterNetworkProxyServer(grpcServer, proxyServer)
```## Client-side
On the client side you may replace a direct connection:
```go
conn, err := net.Dial("tcp", addr)
```
with proxied connection:
```go
conn, err := grpchttpproxy.NewDialer(myGRPCClient).DialContext(ctx, "tcp", addr)
```Or if you need to proxy an HTTP request, you may make an HTTP client:
```go
httpClient := &http.Client{
Transport: &http.Transport{
DialContext: grpchttpproxy.NewDialer(myGRPCClient).DialContext,
},
}
```
And then perform the HTTP requests via this client