{"id":21690787,"url":"https://github.com/reiver/go-telnet","last_synced_at":"2025-05-16T06:05:47.680Z","repository":{"id":57480110,"uuid":"54361636","full_name":"reiver/go-telnet","owner":"reiver","description":"Package telnet provides TELNET and TELNETS client and server implementations, for the Go programming language, in a style similar to the \"net/http\" library that is part of the Go standard library, including support for \"middleware\"; TELNETS is secure TELNET, with the TELNET protocol over a secured TLS (or SSL) connection.","archived":false,"fork":false,"pushed_at":"2023-12-01T21:04:54.000Z","size":171,"stargazers_count":272,"open_issues_count":21,"forks_count":85,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-12T04:44:31.059Z","etag":null,"topics":["rfc-15","rfc-854","telnet","telnet-client","telnet-protocol","telnet-server","telnets"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/reiver/go-telnet","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reiver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-21T05:14:35.000Z","updated_at":"2025-04-09T13:55:29.000Z","dependencies_parsed_at":"2024-06-18T12:40:09.975Z","dependency_job_id":"29ffe00f-031f-4a81-ad6d-b7810b6d5e06","html_url":"https://github.com/reiver/go-telnet","commit_stats":{"total_commits":103,"total_committers":3,"mean_commits":"34.333333333333336","dds":"0.029126213592232997","last_synced_commit":"9ff0b2ab096ebe42bf8e2ffd1366e7ed2223b04c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiver%2Fgo-telnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiver%2Fgo-telnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiver%2Fgo-telnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiver%2Fgo-telnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reiver","download_url":"https://codeload.github.com/reiver/go-telnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478188,"owners_count":22077676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rfc-15","rfc-854","telnet","telnet-client","telnet-protocol","telnet-server","telnets"],"created_at":"2024-11-25T17:33:46.065Z","updated_at":"2025-05-16T06:05:42.663Z","avatar_url":"https://github.com/reiver.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-telnet\n\nPackage **telnet** provides TELNET and TELNETS client and server implementations, for the Go programming language.\n\n\nThe **telnet** package provides an API in a style similar to the \"net/http\" library that is part of the Go standard library, including support for \"middleware\".\n\n\n(TELNETS is *secure TELNET*, with the TELNET protocol over a secured TLS (or SSL) connection.)\n\n\n## Documention\n\nOnline documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-telnet\n\n[![GoDoc](https://godoc.org/github.com/reiver/go-telnet?status.svg)](https://godoc.org/github.com/reiver/go-telnet)\n\n\n## Very Simple TELNET Server Example\n\nA very very simple TELNET server is shown in the following code.\n\nThis particular TELNET server just echos back to the user anything they \"submit\" to the server.\n\n(By default, a TELNET client does *not* send anything to the server until the [Enter] key is pressed.\n\"Submit\" means typing something and then pressing the [Enter] key.)\n\n```\npackage main\n\nimport (\n\t\"github.com/reiver/go-telnet\"\n)\n\nfunc main() {\n\n\tvar handler telnet.Handler = telnet.EchoHandler\n\t\n\terr := telnet.ListenAndServe(\":5555\", handler)\n\tif nil != err {\n\t\t//@TODO: Handle this error better.\n\t\tpanic(err)\n\t}\n}\n\n```\n\nIf you wanted to test out this very very simple TELNET server, if you were on the same computer it was\nrunning, you could connect to it using the bash command:\n```\ntelnet localhost 5555\n```\n(Note that we use the same TCP port number -- \"5555\" -- as we had in our code. That is important, as the\nvalue used by your TELNET server and the value used by your TELNET client **must** match.)\n\n\n## Very Simple (Secure) TELNETS Server Example\n\nTELNETS is the secure version of TELNET.\n\nThe code to make a TELNETS server is very similar to the code to make a TELNET server. \n(The difference between we use the `telnet.ListenAndServeTLS` func instead of the\n`telnet.ListenAndServe` func.)\n\n```\npackage main\n\nimport (\n\t\"github.com/reiver/go-telnet\"\n)\n\nfunc main() {\n\n\tvar handler telnet.Handler = telnet.EchoHandler\n\t\n\terr := telnet.ListenAndServeTLS(\":5555\", \"cert.pem\", \"key.pem\", handler)\n\tif nil != err {\n\t\t//@TODO: Handle this error better.\n\t\tpanic(err)\n\t}\n}\n\n```\n\nIf you wanted to test out this very very simple TELNETS server, get the `telnets` client program from here:\nhttps://github.com/reiver/telnets\n\n\n## TELNET Client Example:\n```\npackage main\n\nimport (\n\t\"github.com/reiver/go-telnet\"\n)\n\nfunc main() {\n\tvar caller telnet.Caller = telnet.StandardCaller\n\n\t//@TOOD: replace \"example.net:5555\" with address you want to connect to.\n\ttelnet.DialToAndCall(\"example.net:5555\", caller)\n}\n```\n\n\n## TELNETS Client Example:\n```\npackage main\n\nimport (\n\t\"github.com/reiver/go-telnet\"\n\n\t\"crypto/tls\"\n)\n\nfunc main() {\n\t//@TODO: Configure the TLS connection here, if you need to.\n\ttlsConfig := \u0026tls.Config{}\n\n\tvar caller telnet.Caller = telnet.StandardCaller\n\n\t//@TOOD: replace \"example.net:5555\" with address you want to connect to.\n\ttelnet.DialToAndCallTLS(\"example.net:5555\", caller, tlsConfig)\n}\n```\n\n\n##  TELNET Shell Server Example\n\nA more useful TELNET servers can be made using the `\"github.com/reiver/go-telnet/telsh\"` sub-package.\n\nFor example:\n```\npackage main\n\n\nimport (\n\t\"github.com/reiver/go-oi\"\n\t\"github.com/reiver/go-telnet\"\n\t\"github.com/reiver/go-telnet/telsh\"\n\n\t\"io\"\n\t\"time\"\n)\n\n\n\nfunc fiveHandler(stdin io.ReadCloser, stdout io.WriteCloser, stderr io.WriteCloser, args ...string) error {\n\toi.LongWriteString(stdout, \"The number FIVE looks like this: 5\\r\\n\")\n\n\treturn nil\n}\n\nfunc fiveProducer(ctx telnet.Context, name string, args ...string) telsh.Handler{\n\treturn telsh.PromoteHandlerFunc(fiveHandler)\n}\n\n\n\nfunc danceHandler(stdin io.ReadCloser, stdout io.WriteCloser, stderr io.WriteCloser, args ...string) error {\n\tfor i:=0; i\u003c20; i++ {\n\t\toi.LongWriteString(stdout, \"\\r⠋\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠙\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠹\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠸\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠼\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠴\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠦\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠧\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠇\")\n\t\ttime.Sleep(50*time.Millisecond)\n\n\t\toi.LongWriteString(stdout, \"\\r⠏\")\n\t\ttime.Sleep(50*time.Millisecond)\n\t}\n\toi.LongWriteString(stdout, \"\\r \\r\\n\")\n\n\treturn nil\n}\n\nfunc danceProducer(ctx telnet.Context, name string, args ...string) telsh.Handler{\n\n\treturn telsh.PromoteHandlerFunc(danceHandler)\n}\n\n\nfunc main() {\n\n\tshellHandler := telsh.NewShellHandler()\n\n\tshellHandler.WelcomeMessage = `\n __          __ ______  _        _____   ____   __  __  ______ \n \\ \\        / /|  ____|| |      / ____| / __ \\ |  \\/  ||  ____|\n  \\ \\  /\\  / / | |__   | |     | |     | |  | || \\  / || |__   \n   \\ \\/  \\/ /  |  __|  | |     | |     | |  | || |\\/| ||  __|  \n    \\  /\\  /   | |____ | |____ | |____ | |__| || |  | || |____ \n     \\/  \\/    |______||______| \\_____| \\____/ |_|  |_||______|\n\n`\n\n\n\t// Register the \"five\" command.\n\tcommandName     := \"five\"\n\tcommandProducer := telsh.ProducerFunc(fiveProducer)\n\n\tshellHandler.Register(commandName, commandProducer)\n\n\n\n\t// Register the \"dance\" command.\n\tcommandName      = \"dance\"\n\tcommandProducer  = telsh.ProducerFunc(danceProducer)\n\n\tshellHandler.Register(commandName, commandProducer)\n\n\n\n\tshellHandler.Register(\"dance\", telsh.ProducerFunc(danceProducer))\n\n\taddr := \":5555\"\n\tif err := telnet.ListenAndServe(addr, shellHandler); nil != err {\n\t\tpanic(err)\n\t}\n}\n```\n\nTELNET servers made using the `\"github.com/reiver/go-telnet/telsh\"` sub-package will often be more useful\nas it makes it easier for you to create a *shell* interface.\n\n\n# More Information\n\nThere is a lot more information about documentation on all this here: http://godoc.org/github.com/reiver/go-telnet\n\n(You should really read those.)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freiver%2Fgo-telnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freiver%2Fgo-telnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freiver%2Fgo-telnet/lists"}