コード例 #1
0
ファイル: client.go プロジェクト: dvbportal/osx-lxd
func unixDial(networ, addr string) (net.Conn, error) {
	var raddr *net.UnixAddr
	var err error
	if addr == "unix.socket:80" {
		raddr, err = net.ResolveUnixAddr("unix", shared.VarPath("unix.socket"))
		if err != nil {
			return nil, fmt.Errorf(gettext.Gettext("cannot resolve unix socket address: %v"), err)
		}
	} else { // TODO - I think this is dead code
		raddr, err = net.ResolveUnixAddr("unix", addr)
		if err != nil {
			return nil, fmt.Errorf(gettext.Gettext("cannot resolve unix socket address: %v"), err)
		}
	}
	return net.DialUnix("unix", nil, raddr)
}
コード例 #2
0
ファイル: config.go プロジェクト: dvbportal/osx-lxd
	// The implicit "local" remote is always available and communicates
	// with the local daemon over a unix socket.
	Remotes map[string]RemoteConfig `yaml:"remotes"`

	// ListenAddr defines an alternative address for the local daemon
	// to listen on. If empty, the daemon will listen only on the local
	// unix socket address.
	ListenAddr string `yaml:"listen-addr"`
}

// RemoteConfig holds details for communication with a remote daemon.
type RemoteConfig struct {
	Addr string `yaml:"addr"`
}

var localRemote = RemoteConfig{Addr: "unix://" + shared.VarPath("unix.socket")}
var defaultRemote = map[string]RemoteConfig{"local": localRemote}

var ConfigDir = "$HOME/.config/lxc"
var configFileName = "config.yml"

func ConfigPath(file string) string {
	return os.ExpandEnv(path.Join(ConfigDir, file))
}

func ServerCertPath(name string) string {
	return path.Join(ConfigPath("servercerts"), fmt.Sprintf("%s.crt", name))
}

// LoadConfig reads the configuration from the config path.
func LoadConfig() (*Config, error) {