Skip to content

Pacakge finger implements the finger protocol, for the Go programming language.

License

Notifications You must be signed in to change notification settings

reiver/go-finger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-finger

Package finger implements the finger-protocol, for the Go programming language.

I.e., generally, what is defined in:

Although this package add some modernizations that are compatible with IETF RFC-742, and in the spirt of the finger-protocol, that you can choose whether to use or not use.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-finger

GoDoc

Simple Finger Client

This is an example of how to create very very very simple finger-protocol client using this package.

It is meant for educational purposes. A more useful finger-protocol client would include a lot more features. But anyway....

We first need to decide what the finger-protocol target will be.

What is a finger-protocol "target"‽

Well, for example, if we were to run the finger program as:

finger joeblow@example.com

Then out target would be:

"joeblow"

So, in our Go code we would have something like:

package main

import (
	"github.com/reiver/go-finger"
)

func main() {

	var target finger.Target = finger.CreateTarget("joeblow")

	//@TODO
}

Now we need to put the target inside of a finger-protocol request.

We do that with the following code:

package main

import (
	"github.com/reiver/go-finger"
)

func main() {

	var target finger.Target = finger.CreateTarget("joeblow")

	var request finger.Request = finger.AssembleRequestTarget(target)

	//@TODO
}

Next, we need to figure out what is the TCP-address of the finger-protocol server our finger-protocol client will connect to.

TCP-addresses (as a string) look something like:

"example.com:79"

"reiver.link:1971"

"181.70.250.13:1079"

"12.23.34.45:7979"

I.e., it is a 'host' and a TCP-port (with a colon ":" between them).

We are using the following as our reference example:

finger joeblow@example.com

So what is our "address"‽

It cannot be just this:

"example.com"

Since it doesn't include a TCP-port.

But, as it turns out, this package can handle this situation. When the TCP-port (in the address) is missing, it defaults it to the default finger-protocol TCP-port. (Which is TCP-port 79.)

So, now our code becomes:

package main

import (
	"github.com/reiver/go-finger"
)

func main() {

	var target finger.Target = finger.CreateTarget("joeblow")

	var request finger.Request = finger.AssembleRequestTarget(target)

	var address finger.Address = finger.CreateAddressHost("example.com")

	//@TODO
}

Now we need to connect to the server. We will do that using net.Dial().

So....

package main

import (
	"github.com/reiver/go-finger"

	"fmt"
	"net"
)

func main() {

	var target finger.Target = finger.CreateTarget("joeblow")

	var request finger.Request = finger.AssembleRequestTarget(target)

	var address finger.Address = finger.CreateAddressHost("example.com")

	conn, err := net.Dial("tcp", address.Resolve())
	if nil != err {
		fmt.Println("ERROR:", err)
		return
	}
	defer conn.Close()

	//@TODO
}

And now we need to create client that will use this TCP connection to make a finger-protocol request.

So, this will create the client:

package main

import (
	"github.com/reiver/go-finger"

	"fmt"
	"net"
)

func main() {

	var target finger.Target = finger.CreateTarget("joeblow")

	var request finger.Request = finger.AssembleRequestTarget(target)

	var address finger.Address = finger.CreateAddressHost("example.com")

	conn, err := net.Dial("tcp", address.Resolve())
	if nil != err {
		fmt.Println("ERROR:", err)
		return
	}
	defer conn.Close()

	var client finger.Client = finger.AssembleClient(conn)

	//@TODO
}

And then this will send the finger-protocol request.

package main

import (
	"github.com/reiver/go-finger"

	"fmt"
	"net"
)

func main() {

	var target finger.Target = finger.CreateTarget("joeblow")

	var request finger.Request = finger.AssembleRequestTarget(target)

	var address finger.Address = finger.CreateAddressHost("example.com")

	conn, err := net.Dial("tcp", address.Resolve())
	if nil != err {
		fmt.Println("ERROR:", err)
		return
	}
	defer conn.Close()

	var client finger.Client = finger.AssembleClient(conn)

	responseReader, err := client.Do(request)
	if nil != err {
		fmt.Println("ERROR:", err)
		return
	}

	//@TODO
}

And finally, this will send the finger-protocol response this program received from the finger-protocol server to STDOUT (so that we can see it):

package main

import (
	"github.com/reiver/go-finger"

	"fmt"
	"io"
	"net"
	"os"
)

func main() {

	var target finger.Target = finger.CreateTarget("joeblow")

	var request finger.Request = finger.AssembleRequestTarget(target)

	var address finger.Address = finger.CreateAddressHost("example.com")

	conn, err := net.Dial("tcp", address.Resolve())
	if nil != err {
		fmt.Println("ERROR:", err)
		return
	}
	defer conn.Close()

	var client finger.Client = finger.AssembleClient(conn)

	responseReader, err := client.Do(request)
	if nil != err {
		fmt.Println("ERROR:", err)
		return
	}

	io.Copy(os.Stdout, responseReader)
}

Unicde UTF-8

This package supports Unicode UTF-8 text encoding for the finger-protocol.

The finger-protocol existed before any IETF RFC was written about it, but —

There are 2 IETF RFCs that are relavent for the finger-protocol:

IETF RFC-742 does not directly or indirectly forbid the use of Unicode UTF-8 — because IETF RFC-742 does not seem to explicitly specify what character-set should be used. IETF RFC-1288 indirectly forbids the use of Unicode UTF-8.

This package sides with the original IETF RFC-742, and supports Unicode UTF-8 text.

This package does this (supports the Unicode UTF-8 encoding of text) to provide a more modern implementation of the finger-protocol.

Someone in the future can write a new IETF RFC for the finger-protocol that gives permission to use the Unicode UTF-8 text encoding.

Import

To import package finger use import code like the follownig:

import "github.com/reiver/go-finger"

Installation

To install package finger do the following:

GOPROXY=direct go get https://github.com/reiver/go-finger

Author

Package finger was written by Charles Iliya Krempeaux

About

Pacakge finger implements the finger protocol, for the Go programming language.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages