@@ -475,20 +475,26 @@ func (s *Server) startLiq(w http.ResponseWriter, r *http.Request) {
475475 AttachStderr : true ,
476476 ExposedPorts : nat.PortSet {
477477 "1234/tcp" : struct {}{},
478+ "8000/tcp" : struct {}{},
478479 },
479480 },
480481 & container.HostConfig {
481482 RestartPolicy : container.RestartPolicy {
482483 Name : "always" ,
483484 MaximumRetryCount : 0 ,
484485 },
485- // use random port since we have multiple containers running
486+ // use random host ports since we have multiple containers running
486487 PortBindings : nat.PortMap {
487488 "1234/tcp" : []nat.PortBinding {
488489 {
489490 HostIP : "0.0.0.0" ,
490491 },
491492 },
493+ "8000/tcp" : []nat.PortBinding {
494+ {
495+ HostIP : "0.0.0.0" ,
496+ },
497+ },
492498 },
493499 },
494500 & network.NetworkingConfig {
@@ -517,18 +523,29 @@ func (s *Server) startLiq(w http.ResponseWriter, r *http.Request) {
517523 return
518524 }
519525 for containerPort , bindings := range resp .NetworkSettings .Ports {
520- fmt .Println ("containerPort" , containerPort )
521- if containerPort .Port () == "1234" {
526+ if len (bindings ) == 1 {
522527 var hostPort string
523- if len (bindings ) == 1 {
524- hostPort = bindings [0 ].HostPort
525- }
526- err := s .db .Q ().SetStationHostPort (ctx , hostPort , station .StationID )
527- if err != nil {
528- http .Error (w , err .Error (), http .StatusInternalServerError )
529- return
528+ hostPort = bindings [0 ].HostPort
529+ fmt .Println ("containerPort" , containerPort , "hostPort" , hostPort )
530+ switch containerPort .Port () {
531+ case "1234" :
532+ err := s .db .Q ().SetStationTelnetPort (ctx , hostPort , station .StationID )
533+ if err != nil {
534+ http .Error (w , err .Error (), http .StatusInternalServerError )
535+ return
536+ }
537+ fmt .Printf ("station %s host port=%s\n " , station .Slug , hostPort )
538+ case "8000" :
539+ err := s .db .Q ().SetStationBroadcastPort (ctx , hostPort , station .StationID )
540+ if err != nil {
541+ http .Error (w , err .Error (), http .StatusInternalServerError )
542+ return
543+ }
544+ fmt .Printf ("station %s host port=%s\n " , station .Slug , hostPort )
530545 }
531- fmt .Printf ("station %s host port=%s\n " , station .Slug , hostPort )
546+ } else {
547+ http .Error (w , "weird, len(bindings)!=1" , http .StatusInternalServerError )
548+ return
532549 }
533550 }
534551
0 commit comments