password of converge now configurable through
CONVERGE_USERNAME and CONVERGE_PASSWORD environment variables.
This commit is contained in:
		
							parent
							
								
									514e57768f
								
							
						
					
					
						commit
						d02b7eade3
					
				| @ -1,6 +1,7 @@ | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	"converge/pkg/comms" | ||||
| 	"converge/pkg/converge" | ||||
| 	"converge/pkg/websocketutil" | ||||
| 	"fmt" | ||||
| @ -70,6 +71,16 @@ func main() { | ||||
| 		printHelp("") | ||||
| 	} | ||||
| 
 | ||||
| 	username, ok := os.LookupEnv("CONVERGE_USERNAME") | ||||
| 	if !ok { | ||||
| 		username = "abc" | ||||
| 	} | ||||
| 
 | ||||
| 	password, ok := os.LookupEnv("CONVERGE_PASSWORD") | ||||
| 	if !ok { | ||||
| 		password = "123" | ||||
| 	} | ||||
| 
 | ||||
| 	admin := converge.NewAdmin() | ||||
| 	registrationService := websocketutil.WebSocketService{ | ||||
| 		Handler: func(w http.ResponseWriter, r *http.Request, conn net.Conn) { | ||||
| @ -79,7 +90,8 @@ func main() { | ||||
| 				return | ||||
| 			} | ||||
| 			log.Printf("Got registration connection: '%s'\n", publicId) | ||||
| 			err = admin.Register(publicId, conn) | ||||
| 			err = admin.Register(publicId, conn, | ||||
| 				comms.UserPassword{Username: username, Password: password}) | ||||
| 			if err != nil { | ||||
| 				log.Printf("Error %v\n", err) | ||||
| 			} | ||||
| @ -168,7 +168,8 @@ func (admin *Admin) RemoveClient(client *Client) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (admin *Admin) Register(publicId string, conn io.ReadWriteCloser) error { | ||||
| func (admin *Admin) Register(publicId string, conn io.ReadWriteCloser, | ||||
| 	userPassword comms.UserPassword) error { | ||||
| 	defer conn.Close() | ||||
| 	// TODO: remove agent return value
 | ||||
| 	agent, err := admin.addAgent(publicId, conn) | ||||
| @ -180,7 +181,7 @@ func (admin *Admin) Register(publicId string, conn io.ReadWriteCloser) error { | ||||
| 	}() | ||||
| 
 | ||||
| 	log.Println("Sending username and password to agent") | ||||
| 	comms.Send(agent.commChannel, comms.UserPassword{Username: "abc", Password: "123"}) | ||||
| 	comms.Send(agent.commChannel, userPassword) | ||||
| 
 | ||||
| 	go func() { | ||||
| 		comms.ListenForAgentEvents(agent.commChannel, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user