Browse Source

run gofmt

pull/2/head
aler9 6 years ago
parent
commit
3617e544c9
  1. 28
      client.go
  2. 8
      main.go

28
client.go

@ -164,14 +164,14 @@ func (c *client) log(format string, args ...interface{}) {
func (c *client) run() { func (c *client) run() {
defer func() { defer func() {
if c.p.postScript != "" { if c.p.postScript != "" {
postScript := exec.Command(c.p.postScript) postScript := exec.Command(c.p.postScript)
err := postScript.Run() err := postScript.Run()
if err != nil { if err != nil {
c.log("ERR: %s", err) c.log("ERR: %s", err)
} }
} }
}() }()
defer c.log("disconnected") defer c.log("disconnected")
@ -187,12 +187,12 @@ func (c *client) run() {
c.log("connected") c.log("connected")
if c.p.preScript != "" { if c.p.preScript != "" {
preScript := exec.Command(c.p.preScript) preScript := exec.Command(c.p.preScript)
err := preScript.Run() err := preScript.Run()
if err != nil { if err != nil {
c.log("ERR: %s", err) c.log("ERR: %s", err)
} }
} }
for { for {
req, err := c.conn.ReadRequest() req, err := c.conn.ReadRequest()

8
main.go

@ -54,7 +54,7 @@ type program struct {
rtpPort int rtpPort int
rtcpPort int rtcpPort int
publishKey string publishKey string
preScript string preScript string
postScript string postScript string
mutex sync.RWMutex mutex sync.RWMutex
rtspl *serverTcpListener rtspl *serverTcpListener
@ -112,8 +112,8 @@ func newProgram(protocolsStr string, rtspPort int, rtpPort int, rtcpPort int, pu
if preScript != "" { if preScript != "" {
if runtime.GOOS != "linux" { if runtime.GOOS != "linux" {
return nil, fmt.Errorf("connect script currenty supported only on Linux") return nil, fmt.Errorf("connect script currenty supported only on Linux")
} else if !regexp.MustCompile(`(?m)^(.+)\/([^/]+)$`).MatchString(preScript) { } else if !regexp.MustCompile(`(?m)^(.+)\/([^/]+)$`).MatchString(preScript) {
return nil, fmt.Errorf("connect script must be a valid path") return nil, fmt.Errorf("connect script must be a valid path")
} }
} }
@ -121,7 +121,7 @@ func newProgram(protocolsStr string, rtspPort int, rtpPort int, rtcpPort int, pu
if runtime.GOOS != "linux" { if runtime.GOOS != "linux" {
return nil, fmt.Errorf("disconnect script currently supported only on Linux") return nil, fmt.Errorf("disconnect script currently supported only on Linux")
} else if !regexp.MustCompile(`(?m)^(.+)\/([^/]+)$`).MatchString(postScript) { } else if !regexp.MustCompile(`(?m)^(.+)\/([^/]+)$`).MatchString(postScript) {
return nil, fmt.Errorf("disconnect script must be a valid path") return nil, fmt.Errorf("disconnect script must be a valid path")
} }
} }

Loading…
Cancel
Save