Skip to content

Commit def6fc6

Browse files
committed
Pre-validate protocol
Resolves #32
1 parent 0308a0c commit def6fc6

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

api/api.go

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ var (
6060
NoServerError = errors.New("No Server Found")
6161
NoServiceError = errors.New("No Service Found")
6262
BadListenAddr = errors.New("Port Already In Use")
63+
ErrBadProto = errors.New("Unsupported Protocol")
6364
)
6465

6566
type (

api/service.go

+5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ func checkPort(svc core.Service) error {
7575
return BadListenAddr
7676
}
7777
}
78+
79+
if svc.Type != "udp" && svc.Type != "tcp" {
80+
return ErrBadProto
81+
}
82+
7883
return nil
7984
}
8085

balance/nginx.go

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ func (n *Nginx) DeleteServer(svcId, srvId string) error {
241241

242242
// regenerloadConfig regenerates the nginx config and performs a live reload on
243243
// nginx to re-read in the config.
244+
// todo: use http proxying if http detected
244245
func (n *Nginx) regenerloadConfig() error {
245246
nginxConfig := fmt.Sprintf(`%s
246247

0 commit comments

Comments
 (0)