mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Fix getself, gettuntap etc
This commit is contained in:
		
							parent
							
								
									31c1c9b586
								
							
						
					
					
						commit
						058dec0cca
					
				
					 2 changed files with 22 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -10,22 +10,28 @@ import (
 | 
			
		|||
type GetSelfRequest struct{}
 | 
			
		||||
 | 
			
		||||
type GetSelfResponse struct {
 | 
			
		||||
	Self map[string]SelfEntry `json:"self"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type SelfEntry struct {
 | 
			
		||||
	BuildName    string   `json:"build_name"`
 | 
			
		||||
	BuildVersion string   `json:"build_version"`
 | 
			
		||||
	PublicKey    string   `json:"key"`
 | 
			
		||||
	Coords       []uint64 `json:"coords"`
 | 
			
		||||
	IPAddress    string   `json:"address"`
 | 
			
		||||
	Subnet       string   `json:"subnet"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *AdminSocket) getSelfHandler(req *GetSelfRequest, res *GetSelfResponse) error {
 | 
			
		||||
	res.BuildName = version.BuildName()
 | 
			
		||||
	res.BuildVersion = version.BuildVersion()
 | 
			
		||||
	res.Self = make(map[string]SelfEntry)
 | 
			
		||||
	public := a.core.PrivateKey().Public().(ed25519.PublicKey)
 | 
			
		||||
	res.PublicKey = hex.EncodeToString(public[:])
 | 
			
		||||
	res.IPAddress = a.core.Address().String()
 | 
			
		||||
	addr := a.core.Address().String()
 | 
			
		||||
	snet := a.core.Subnet()
 | 
			
		||||
	res.Subnet = snet.String()
 | 
			
		||||
	// TODO: res.coords
 | 
			
		||||
	res.Self[addr] = SelfEntry{
 | 
			
		||||
		BuildName:    version.BuildName(),
 | 
			
		||||
		BuildVersion: version.BuildVersion(),
 | 
			
		||||
		PublicKey:    hex.EncodeToString(public[:]),
 | 
			
		||||
		Subnet:       snet.String(),
 | 
			
		||||
		// TODO: coords
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue