-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a2327e
commit 0c1d070
Showing
19 changed files
with
1,061 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cfc | ||
|
||
import ( | ||
"github.com/peakedshout/go-CFC/client" | ||
"github.com/peakedshout/go-CFC/server" | ||
"net" | ||
) | ||
|
||
type Listener struct { | ||
box *client.DeviceBox | ||
} | ||
|
||
func (ln *Listener) Accept() (conn net.Conn, err error) { | ||
return ln.box.ListenSubBoxOnce() | ||
} | ||
func (ln *Listener) Close() error { | ||
return ln.box.Close() | ||
} | ||
func (ln *Listener) Addr() net.Addr { | ||
return nil | ||
} | ||
|
||
func Listen(lname string, proxyAddr string, key string) (net.Listener, error) { | ||
box, err := client.LinkProxyServer(lname, proxyAddr, key) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &Listener{box: box}, nil | ||
} | ||
|
||
type Dialer struct { | ||
box *client.DeviceBox | ||
} | ||
|
||
func (dl *Dialer) Close() error { | ||
return dl.box.Close() | ||
} | ||
|
||
func (dl *Dialer) Call(rname string) (net.Conn, error) { | ||
return dl.box.GetSubBox(rname) | ||
} | ||
func Dial(lname string, proxyAddr string, key string) (*Dialer, error) { | ||
box, err := client.LinkProxyServer(lname, proxyAddr, key) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &Dialer{box: box}, nil | ||
} | ||
|
||
func Proxy(proxyAddr string, key string) *server.ProxyServer { | ||
return server.NewProxyServer(proxyAddr, key) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.