// NewCloudflaredMethod creates a new CloudflaredMethod with the given fields.
NewCloudflaredMethod creates a new CloudflaredMethod with the given fields.
// NewCloudflaredMethod creates a new CloudflaredMethod with the given fields .
func NewCloudflaredMethod(client *http.Client, output io.Writer, input *bufio.Reader) (*CloudflaredMethod, error) {
	home := strings.TrimSpace(os.Getenv("HOME"))
	if home == "" {
		curr, err := user.Current()
		if err != nil {
			return nil, fmt.Errorf("can not get users home directory")
		}
		home = curr.HomeDir
	}
	if client == nil {
		client = http.DefaultClient
	}
	return &CloudflaredMethod{
		mwriter:   NewMessageWriter(output),
		mreader:   NewMessageReader(input),
		datapath:  path.Join(home, ".cloudflared/cfd/servicetokens/"),
		urlwriter: NewURLWriter(os.Stderr, "Auth URL: "),
		client:    client,
		transport: client.Transport,
	}, nil
}
func NewCloudflaredMethod ( client * http . Client , output io . Writer , input * bufio . Reader ) ( * CloudflaredMethod , error ) { home := strings . TrimSpace ( os . Getenv ( " " ) ) if home == " " { curr , err := user . Current ( ) if err != nil { return nil , fmt . Errorf ( " " ) } home = curr . HomeDir } if client == nil { client = http . DefaultClient } return & CloudflaredMethod { mwriter : NewMessageWriter ( output ) , mreader : NewMessageReader ( input ) , datapath : path . Join ( home , " " ) , urlwriter : NewURLWriter ( os . Stderr , " " ) , client : client , transport : client . Transport , } , nil }
NewCloudflaredMethod creates a new CloudflaredMethod with the given fields.
NewCloudflaredMethod creates a new CloudflaredMethod with the given fields .
// Attempt to parse together the default location. // Note: we run as root, so this means that our HOME directory is not the // users home directory. That said, os.Getenv("HOME") should still return // the users home directory. Always prefer the value of $HOME, though fall // back to asking for the user value from os/user.