Пример #1
0
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
	// 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) {