cfc

package module
v1.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2023 License: MIT Imports: 3 Imported by: 0

README


go-CFC

A communication connection agent based on golang development, the goal is simple, efficient, stable, secure, and extensible.

简体中文/English

What is go-cfc(Cloud fog connection)?

  • This is a simple communication agent, you can think of it as a little toy, it is highly extensible, can surprise (or scare)
  • Note that it's not a vpn, and it's much lighter than a vpn, which means it's less cumbersome
  • Huh? You're right, it's not very technical. If you can sum it up in one sentence, it's an io.Copy of two net.Conn's, you can write one

What can go-cfc do?

  • It can perform Intranet penetration to connect two devices
  • The price of a server is not cheap, if the performance is still high, the cost will be heavy, computing to the local device, the server only needs to forward the data delivery, although the response speed is sacrificed, but it will reduce the cost of computing performance
  • It has a built-in communication protocol, and you can even use the protocol directly

Why is this thing here?

  • I just wanted to ssh my raspberry PI
  • I dug up a raspberry PI that I didn't use for a long time, and I wanted to do something with it, but my energy was limited, and I had a job, and I couldn't ssh the Raspberry PI for development whenever I wanted
  • Sometimes, I want to ssh my Raspberry PI at work to see things or install software
  • But I couldn't ssh my Raspberry PI, because Raspberry PI was at home and I was in the company, so I couldn't directly connect the two Intranet
  • I was annoyed, but I didn't want to install someone else's Intranet penetration tool (cumbersome and difficult to understand), so I wrote this to solve the Raspberry PI problem in ssh's home
  • But, obviously, it's not just for ssh, and maybe you can use it for other things
  • It even helped me save installing unnecessary tools at work, after all, some environment variable Settings are tedious, right?

How to use it?

  • It's essentially a tool library, but if you want to use it directly, you can just use the compiled ones here.
    • proxy server:
      ./cfc_hook_server -c config.json
      
      device client:
      ./cfc_hook_client -c config.json
      
  • proxy server(Proxy server)
    • import "github.com/peakedshout/go-CFC/server"
    • package example
      
      import "github.com/peakedshout/go-CFC/server"   
      
      func example(){
          server.NewProxyServer("Proxy Server Addr", "32bytes key").Wait()
      } 
      
  • server listen (Listening connection)
    • import "github.com/peakedshout/go-CFC/client"
    • package example
      
      import "github.com/peakedshout/go-CFC/client"
      
      func example()  {
          box,_:=client.LinkProxyServer("server name","Proxy Server Addr", "32bytes key")
          defer box.Close()
          box.ListenSubBox(func(sub *client.SubBox){
              defer sub.Close()
          })
          box.Wait()
      }
      
  • client dial (Request connection)
    • import "github.com/peakedshout/go-CFC/client"
    • package example
      
      import "github.com/peakedshout/go-CFC/client"
      
      func example()  {
          box,_:=client.LinkProxyServer("client name","Proxy Server Addr", "32bytes key")
          defer box.Close()
          sub,_:=box.GetSubBox("server name")
          defer sub.Close()
      }
      
  • sub interface (Connection interface)
    • import "github.com/peakedshout/go-CFC/client"
    • package example
      
      import "github.com/peakedshout/go-CFC/client"
      
      func example()  {
          //var sub *client.SubBox
          //Read(b []byte) (int, error)
          //Write(b []byte) (int, error)
          //Close() error
          //LocalAddr() net.Addr
          //RemoteAddr() net.Addr
          //SetDeadline(t time.Time) error
          //SetReadDeadline(t time.Time) error
          //SetWriteDeadline(t time.Time) error
          //GetLocalName() string
          //GetRemoteName() string
          //SetDeadlineDuration(timeout time.Duration) bool
          //NewKey(key string) tool.Key
          //GetNetworkSpeedView() tool.NetworkSpeedView
          //GetAllNetworkSpeedView() tool.NetworkSpeedView
          //ReadCMsgCb(fn func(cMsg tool.ConnMsg) (bool, error)) error
          //WriteCMsg(header string, id string, code int, data interface{}) error
          //WriteQueueBytes(b [][]byte) error
      }
      

Features you want to support (later?)

  • Support tcp connection
  • Support for obtaining one end delay
  • Download files on special links
  • Supports subkey encryption
  • Support connection check
  • Support for obtaining network speed
  • p2p support

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(lname string, proxyAddr string, key string) (net.Listener, error)

func Proxy

func Proxy(proxyAddr string, key string) *server.ProxyServer

func ProxyConfig added in v1.3.7

func ProxyConfig(config *server.Config) *server.ProxyServer

Types

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

func Dial

func Dial(lname string, proxyAddr string, key string) (*Dialer, error)

func (*Dialer) Call

func (dl *Dialer) Call(rname string) (net.Conn, error)

func (*Dialer) CallMix added in v1.3.7

func (dl *Dialer) CallMix(rname string, subTypes []client.SubType) (net.Conn, error)

func (*Dialer) CallUP2P added in v1.3.6

func (dl *Dialer) CallUP2P(rname string) (net.Conn, error)

func (*Dialer) Close

func (dl *Dialer) Close() error

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

func (*Listener) Accept

func (ln *Listener) Accept() (conn net.Conn, err error)

func (*Listener) Addr

func (ln *Listener) Addr() net.Addr

func (*Listener) Close

func (ln *Listener) Close() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL