コード例 #1
0
ファイル: standalone_proxy.go プロジェクト: rallen71366/Dust
func dustProxy(dustSide *Dust.RawStreamConn, plainSide *net.TCPConn) error {
	var ctl proc.Ctl
	penv := proc.InitChild(nil, &ctl, noProcess)
	_ = proc.InitHelper(penv, managedCopy(plainSide, dustSide, 4096))
	_ = proc.InitHelper(penv, managedCopy(dustSide, plainSide, 4096))
	ctl.Start()
	_ = <-ctl.Exit
	err := ctl.Status()
	log.Info("closing")
	dustSide.Close()
	plainSide.Close()
	log.Info("done: %v", err)
	return err
}
コード例 #2
0
ファイル: shaper.go プロジェクト: rallen71366/Dust
// NewShaper initializes a new shaper process object for the outward-facing side of crypter, using in/out for
// receiving and sending shaped data and decoder/encoder as the model for this side of the Dust connection.
// The shaper will not be running.  Call Start() on the shaper afterwards to start it in the background.
func NewShaper(
	parent *proc.Env,
	crypter *crypting.Session,
	in io.Reader,
	decoder Decoder,
	out io.Writer,
	encoder Encoder,
) (*Shaper, error) {
	sh := &Shaper{}
	env := proc.InitChild(parent, &sh.Ctl, sh.runShaper)
	sh.incoming.Init(env, crypter.Back, in, decoder)
	sh.outgoing.Init(env, out, crypter.Back, encoder)
	return sh, nil
}