Unverified Commit b50a3756 authored by G33tha's avatar G33tha Committed by GitHub
Browse files

Merge pull request #3010 from rjshrjndrn/merge-branch

Merge 4.2.0 to 4.3.0
Showing with 79 additions and 1 deletion
+79 -1
......@@ -599,7 +599,8 @@ collection {
allowedContentTypes = ["TextBook","Collection","Course"]
maxFirstLevelUnits=30
ttl = 86400
maxUnitFieldLength=120
maxDescFieldLength=1500
contentTypeToUnitType = {"TextBook": "TextBookUnit", "Course": "CourseUnit", "Collection":"Collection"}
headers {
folderIdentifier = ["Folder Identifier"]
......
......@@ -171,6 +171,7 @@ sunbird_google_oauth_ios_clientSecret={{sunbird_google_oauth_ios_clientSecret |
#Release-4.2.0
#variable for the crypto key to encrypt any content or userinfo that will be used by the external sunbird users
crypto_encryption_key_external={{crypto_encryption_key_external|default("")}}
vdnURL={{vdnURL|default("")}}
#Release-4.3.0
# default token for device register API fallback
......
## Usage
This application will help to debug network communication via TCP by proxying the connection while printing the data to terminal console. For example, if ApplicationA -> ApplicationB and there is some issue in the data recieved by ApplicationB, you can run ApplicationA -> tcp_proxy -> ApplicationB.
ApplicationB listens to 8080
We'll start tcp_proxy as `./tcp_proxy -l 0.0.0.0:9999 -r localhost:8080` in ApplicationB Machine. Then we'll remap, ApplicationA to point to `APplicationB machine ip address:8080`, which will proxy to applicationB while printing the data to terminal.
## Build
`CGO_ENABLED=0 go build -o tcp_proxy ./main.go`
module github.com/project-sunbird/sunbird-devops/exporters/Go/tcp-logger
go 1.17
// vim: set nofoldenable:
// Author: rjshrjdnrn <rjshrjndrn@gmail.com>
// This application will proxy tcp connecion while printing the logs to console.
package main
import (
"flag"
"fmt"
"io"
"log"
"net"
"os"
)
var localAddr *string = flag.String("l", "localhost:9999", "local address")
var remoteAddr *string = flag.String("r", "localhost:8888", "remote address")
func main() {
flag.Parse()
fmt.Printf("Listening: %v\nProxying: %v\n\n", *localAddr, *remoteAddr)
listener, err := net.Listen("tcp", *localAddr)
if err != nil {
panic(err)
}
for {
// Creating a listener
conn, err := listener.Accept()
log.Println("New connection", conn.RemoteAddr())
if err != nil {
log.Println("error accepting connection", err)
continue
}
go func() {
// Closing the listener
defer conn.Close()
// Creating connection to remote server, proxy connection.
conn2, err := net.Dial("tcp", *remoteAddr)
if err != nil {
log.Println("error dialing remote addr", err)
return
}
// Closing proxy connection
defer conn2.Close()
// Creating channel to copy the data
closer := make(chan struct{}, 2)
// Copy local data to remotet server
go copy(closer, conn2, conn)
// Copy proxy data to local listener
go copy(closer, conn, conn2)
// Waiting for the data to be written
<-closer
log.Println("Connection complete", conn.RemoteAddr())
}()
}
}
func copy(closer chan struct{}, dst io.Writer, src io.Reader) {
io.Copy(os.Stdout, io.TeeReader(src, dst))
closer <- struct{}{} // connection is closed, send signal to stop proxy
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment