46 lines
		
	
	
		
			747 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			747 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package models
 | |
| 
 | |
| import (
 | |
| 	"net"
 | |
| )
 | |
| 
 | |
| type HMNetInfo struct {
 | |
| 	IP     net.IP `json:"ip"`
 | |
| 	WebURL string `json:"web_url,omitempty"`
 | |
| 	SSH    struct {
 | |
| 		User    string `json:"user"`
 | |
| 		PrivKey string `json:"privkey"`
 | |
| 		Port    int    `json:"port"`
 | |
| 	} `json:"ssh,omitempty"`
 | |
| }
 | |
| 
 | |
| type (
 | |
| 	HMVM  map[string]*HMNetInfo
 | |
| 	HMLXC map[string]*HMNetInfo
 | |
| )
 | |
| 
 | |
| // HMMap handles all the informations of your home server instances.
 | |
| type HMMap struct {
 | |
| 	*HMNetInfo
 | |
| 	VM  HMVM  `json:"vm,omitempty"`
 | |
| 	LXC HMLXC `json:"lxc,omitempty"`
 | |
| }
 | |
| 
 | |
| func (hm *HMMap) GetSwarmNetInfo() *HMNetInfo {
 | |
| 	data, ok := hm.VM["swarm"]
 | |
| 	if !ok {
 | |
| 		return nil
 | |
| 	}
 | |
| 
 | |
| 	return data
 | |
| }
 | |
| 
 | |
| func (hm *HMMap) GetNginxNetInfo() *HMNetInfo {
 | |
| 	data, ok := hm.LXC["nginx"]
 | |
| 	if !ok {
 | |
| 		return nil
 | |
| 	}
 | |
| 
 | |
| 	return data
 | |
| }
 | 
