-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,118 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
VERSION=$(shell git describe --tags) | ||
LDFLAGS=-ldflags "-s -w" | ||
|
||
all: linux | ||
|
||
release: all zip | ||
|
||
clean: | ||
rm -rf bin/* *.zip | ||
|
||
upx: | ||
upx -9 bin/* | ||
|
||
linux: | ||
CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -o bin/server-linux-amd64 ${LDFLAGS} cmd/main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Flutter Webapp server | ||
### Features | ||
|
||
- WebRTC server for flutter app | ||
- Image to text translation | ||
|
||
### Run Binary(Only Linux) | ||
|
||
- Run | ||
|
||
```bash | ||
./bin/server-linux-amd64 | ||
``` | ||
|
||
Open https://0.0.0.0:8086. | ||
|
||
### Compile from Source | ||
|
||
- Install [tesseract-ocr](https://github.com/tesseract-ocr/tesseract/wiki) | ||
- Go is required in the system | ||
- Clone the repository, run `make`. | ||
- Run `./bin/server-{platform}-{arch}`. | ||
- Your server is live. | ||
|
||
## Note | ||
|
||
This example can only be used for LAN testing. If you need to use it in a production environment, you need more testing and and deploy an available turn server. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/openemr/app-golang-openemr/pkg/logger" | ||
"github.com/openemr/app-golang-openemr/pkg/signaler" | ||
"github.com/openemr/app-golang-openemr/pkg/turn" | ||
"github.com/openemr/app-golang-openemr/pkg/websocket" | ||
"gopkg.in/ini.v1" | ||
) | ||
|
||
func main() { | ||
|
||
cfg, err := ini.Load("./../configs/config.ini") | ||
if err != nil { | ||
logger.Errorf("Fail to read file: %v", err) | ||
os.Exit(1) | ||
} | ||
|
||
publicIP := cfg.Section("turn").Key("public_ip").String() | ||
stunPort, err := cfg.Section("turn").Key("port").Int() | ||
if err != nil { | ||
stunPort = 3478 | ||
} | ||
realm := cfg.Section("turn").Key("realm").String() | ||
|
||
turnConfig := turn.DefaultConfig() | ||
turnConfig.PublicIP = publicIP | ||
turnConfig.Port = stunPort | ||
turnConfig.Realm = realm | ||
turn := turn.NewTurnServer(turnConfig) | ||
|
||
signaler := signaler.NewSignaler(turn) | ||
wsServer := websocket.NewWebSocketServer(signaler.HandleNewWebSocket, signaler.HandleTurnServerCredentials) | ||
|
||
sslCert := cfg.Section("general").Key("cert").String() | ||
sslKey := cfg.Section("general").Key("key").String() | ||
bindAddress := cfg.Section("general").Key("bind").String() | ||
|
||
port, err := cfg.Section("general").Key("port").Int() | ||
if err != nil { | ||
port = 8086 | ||
} | ||
|
||
htmlRoot := cfg.Section("general").Key("html_root").String() | ||
|
||
config := websocket.DefaultConfig() | ||
config.Host = bindAddress | ||
config.Port = port | ||
config.CertFile = sslCert | ||
config.KeyFile = sslKey | ||
config.HTMLRoot = htmlRoot | ||
|
||
wsServer.Bind(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIECzCCA7GgAwIBAgIQCBxMTCshRajzZ4m6y26g8TAKBggqhkjOPQQDAjByMQs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AdBgNVHSUE | ||
FjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwEgYDVR0TAQH/BAgwBgEB/wIBADA0Bggr | ||
BgEFBQcBAQQoMCYwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNv | ||
bTBCBgNVHR8EOzA5MDegNaAzhjFodHRwOi8vY3JsMy5kaWdpY2VydC5jb20vRGln | ||
aUNlcnRHbG9iYWxSb290Q0EuY3JsMEwGA1UdIARFMEMwNwYJYIZIAYb9bAECMCow | ||
KAYIKwYBBQUHAgEWHGh0dHBzOi8vd3d3LmRpZ2ljZXJ0LmNvbS9DUFMwCAYGZ4EM | ||
AQIBMA0GCSqGSIb3DQEBCwUAA4IBAQBZcGGhLE09CbQD5xP93NAuNC85G1BMa1OG | ||
2Q01TWvvgp7Qt1wNfRLAnhQT5pb7kRs+E7nM4IS894ufmuL452q8gYaq5HmvOmfh | ||
XMmL6K+eICfvyqjb/tSi8iy20ULO/TZhLhPor9tle52Yx811FG4i5vqwPIUEOEJ7 | ||
pXe6RPVoBiwi4rbLspQGD/vYqrj9OJV4JctoIhhGq+y/sozU6nBXHfhVSD3x+hkO | ||
Ost6tyRq481IyUWQHcFtwda3gfMnaA3dsag2dtJz33RIJIUfxXmVK7w4YzHOHifn | ||
7TYk8iNrDDLtql6vS8FjiUx3kJnI6zge1C9lUHhZ/aD3RiTJrwWI | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg5IB7nx+zBYxQ9HNx | ||
wRnmQ5ySsXH/i66wdqxxIOYYqYKhRANCAATXEqrYLiHRTiy4YwMe24gdAdOm2GNp | ||
IWDqBNz0wYhp2Zlxq5s4T+g88iy31cKI6MLGPhHB/OdG7f2bmfZEgU0s | ||
-----END PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[general] | ||
domain=demo.example.com | ||
cert=./../configs/certs/cert.pem | ||
key=./../configs/certs/key.pem | ||
bind=0.0.0.0 | ||
port=8086 | ||
|
||
[turn] | ||
public_ip=127.0.0.1 | ||
port=19302 | ||
realm=flutter-webrtc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module github.com/openemr/app-golang-openemr | ||
|
||
go 1.12 | ||
|
||
require ( | ||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 | ||
github.com/gorilla/mux v1.7.3 // indirect | ||
github.com/gorilla/websocket v1.4.1 | ||
github.com/otiai10/gosseract/v2 v2.2.4 | ||
github.com/otiai10/mint v1.3.2 // indirect | ||
github.com/pion/turn/v2 v2.0.3 | ||
github.com/rs/zerolog v1.14.3 | ||
github.com/smartystreets/goconvey v1.6.4 // indirect | ||
gopkg.in/ini.v1 v1.51.1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4= | ||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9/go.mod h1:2wSM9zJkl1UQEFZgSd68NfCgRz1VL1jzy/RjCg+ULrs= | ||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= | ||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= | ||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= | ||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= | ||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= | ||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | ||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= | ||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= | ||
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= | ||
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= | ||
github.com/otiai10/gosseract/v2 v2.2.4 h1:h/PV+oJqke8q2Ccw9bjpMBWfd7N2vtGDCUcihZj3nRo= | ||
github.com/otiai10/gosseract/v2 v2.2.4/go.mod h1:ahOp/kHojnOMGv1RaUnR0jwY5JVa6BYKhYAS8nbMLSo= | ||
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= | ||
github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E= | ||
github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= | ||
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= | ||
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= | ||
github.com/pion/stun v0.3.3 h1:brYuPl9bN9w/VM7OdNzRSLoqsnwlyNvD9MVeJrHjDQw= | ||
github.com/pion/stun v0.3.3/go.mod h1:xrCld6XM+6GWDZdvjPlLMsTU21rNxnO6UO8XsAvHr/M= | ||
github.com/pion/transport v0.8.10 h1:lTiobMEw2PG6BH/mgIVqTV2mBp/mPT+IJLaN8ZxgdHk= | ||
github.com/pion/transport v0.8.10/go.mod h1:tBmha/UCjpum5hqTWhfAEs3CO4/tHSg0MYRhSzR+CZ8= | ||
github.com/pion/turn v1.4.0 h1:7NUMRehQz4fIo53Qv9ui1kJ0Kr1CA82I81RHKHCeM80= | ||
github.com/pion/turn/v2 v2.0.1 h1:TO6NsNCqSIrhk33Eg3l7+KPeUOjLY3Ff70l+DAxAQOQ= | ||
github.com/pion/turn/v2 v2.0.1/go.mod h1:kl1hmT3NxcLynpXVnwJgObL8C9NaCyPTeqI2DcCpSZs= | ||
github.com/pion/turn/v2 v2.0.3 h1:SJUUIbcPoehlyZgMyIUbBBDhI03sBx32x3JuSIBKBWA= | ||
github.com/pion/turn/v2 v2.0.3/go.mod h1:kl1hmT3NxcLynpXVnwJgObL8C9NaCyPTeqI2DcCpSZs= | ||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= | ||
github.com/rs/zerolog v1.14.3 h1:4EGfSkR2hJDB0s3oFfrlPqjU1e4WLncergLil3nEKW0= | ||
github.com/rs/zerolog v1.14.3/go.mod h1:3WXPzbXEEliJ+a6UFE4vhIxV8qR1EML6ngzP9ug4eYg= | ||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= | ||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= | ||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= | ||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= | ||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | ||
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/ini.v1 v1.51.1 h1:GyboHr4UqMiLUybYjd22ZjQIKEJEpgtLXtuGbR21Oho= | ||
gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package logger | ||
|
||
import ( | ||
"os" | ||
"time" | ||
|
||
"github.com/rs/zerolog" | ||
) | ||
|
||
var log zerolog.Logger | ||
|
||
// Level defines log levels. | ||
type Level uint8 | ||
|
||
const ( | ||
// DebugLevel defines debug log level. | ||
DebugLevel Level = iota | ||
// InfoLevel defines info log level. | ||
InfoLevel | ||
// WarnLevel defines warn log level. | ||
WarnLevel | ||
// ErrorLevel defines error log level. | ||
ErrorLevel | ||
// FatalLevel defines fatal log level. | ||
FatalLevel | ||
// PanicLevel defines panic log level. | ||
PanicLevel | ||
// NoLevel defines an absent log level. | ||
NoLevel | ||
// Disabled disables the logger. | ||
Disabled | ||
) | ||
|
||
func init() { | ||
zerolog.SetGlobalLevel(zerolog.DebugLevel) | ||
output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339} | ||
log = zerolog.New(output).With().Timestamp().Logger() | ||
SetLevel(DebugLevel) | ||
} | ||
|
||
func SetLevel(l Level) { | ||
zerolog.SetGlobalLevel(zerolog.Level(l)) | ||
} | ||
|
||
func Infof(format string, v ...interface{}) { | ||
log.Info().Msgf(format, v...) | ||
} | ||
|
||
func Debugf(format string, v ...interface{}) { | ||
log.Debug().Msgf(format, v...) | ||
} | ||
|
||
func Warnf(format string, v ...interface{}) { | ||
log.Warn().Msgf(format, v...) | ||
} | ||
|
||
func Errorf(format string, v ...interface{}) { | ||
log.Error().Msgf(format, v...) | ||
} | ||
|
||
func Panicf(format string, v ...interface{}) { | ||
log.Panic().Msgf(format, v...) | ||
} |
Oops, something went wrong.