Compare commits
294 Commits
pre-releas
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
c69d11d17d | ||
|
e9bc3f0131 | ||
|
f719846bf3 | ||
|
adfc112d1a | ||
|
ba9326e417 | ||
|
e9887233c0 | ||
|
09c61da056 | ||
|
721607826e | ||
|
113b502abb | ||
|
ddca6a4663 | ||
|
8dd044c7cf | ||
|
4b7715e6b3 | ||
|
546ac8d62b | ||
|
3557ea60a6 | ||
|
bf3eae1d9a | ||
|
2204b28af9 | ||
|
b63b83b3ae | ||
|
8c8f4d36d0 | ||
|
338566985b | ||
|
b87a2ba840 | ||
|
5b6a8fa028 | ||
|
63c17b7d51 | ||
|
e0ee2822cd | ||
|
41f09daf42 | ||
|
5b8ba12cb3 | ||
|
48c794023a | ||
|
a7160c58c8 | ||
|
c7263e39bc | ||
|
31530f8a43 | ||
|
df86da4964 | ||
|
9bab150922 | ||
|
a1cadb5846 | ||
|
e51731714f | ||
|
16c534e1a9 | ||
|
87c10e562e | ||
|
f426ca26f2 | ||
|
d92d17c15d | ||
|
e8f5de568d | ||
|
936288058d | ||
|
26c419f564 | ||
|
1b7cb8c9cb | ||
|
b283514f9e | ||
|
7ffe343767 | ||
|
1bbfd5e152 | ||
|
b3c5d03af2 | ||
|
34f516b2a3 | ||
|
3c45888a60 | ||
|
9877e9c78c | ||
|
7b994ecb8b | ||
|
09f7e952a8 | ||
|
d594befc45 | ||
|
89a04d154e | ||
|
95e1bbdfce | ||
|
5a052e7c36 | ||
|
8d7f5fc498 | ||
|
ca691bc144 | ||
|
369e2f7d92 | ||
|
3bd9836cad | ||
|
8014af3818 | ||
|
accff3a5d0 | ||
|
f52fbd77b8 | ||
|
1a6bccdf00 | ||
|
270ae4543b | ||
|
e03ea9c60f | ||
|
fcfa1612c8 | ||
|
74c1318f53 | ||
|
276767a32e | ||
|
6b2ae89167 | ||
|
d8fe9758e4 | ||
|
316d5ff442 | ||
|
7d431a7bd6 | ||
|
94e587399d | ||
|
d0e3ffbb17 | ||
|
61a056c768 | ||
|
7a96f37541 | ||
|
c2428c871f | ||
|
2f5a86498c | ||
|
2c4004d254 | ||
|
c197990c79 | ||
|
64f73c4f04 | ||
|
7706bf250f | ||
|
3ae13e0381 | ||
|
bfed9b4320 | ||
|
3913c1c91e | ||
|
b63ea16697 | ||
|
7f05f2fe17 | ||
|
736ad294e7 | ||
|
dd3603c341 | ||
|
1eed97f0f8 | ||
|
82c3acf3b1 | ||
|
782991c356 | ||
|
163fd0537c | ||
|
26fc4127a9 | ||
|
a9fbc070ac | ||
|
817b5c8133 | ||
|
dcb153c8a4 | ||
|
1ca998e9e3 | ||
|
cd23910b1a | ||
|
fdf9c77d51 | ||
|
790edc5fa7 | ||
|
4109b117fe | ||
|
77ac0b8e58 | ||
|
fd2fb99394 | ||
|
f157dbe9d3 | ||
|
603c65063b | ||
|
f66f0d0443 | ||
|
f61763f716 | ||
|
6c62ab74b7 | ||
|
679a3247c6 | ||
|
55674f1928 | ||
|
d674aa1120 | ||
|
bffd82185c | ||
|
81afdc770e | ||
|
5c8eb10598 | ||
|
28f8e61de8 | ||
|
aa86a34b76 | ||
|
bf03b23ca0 | ||
|
9a25dc85f9 | ||
|
d51cec2925 | ||
|
97c080dc59 | ||
|
84187ce11e | ||
|
235c9f5893 | ||
|
66ce5dd114 | ||
|
d70ed90ba7 | ||
|
fa09e03b99 | ||
|
a235654c03 | ||
|
8deba623b6 | ||
|
4b85419943 | ||
|
108a7d822b | ||
|
1348da265e | ||
|
536d186b5c | ||
|
85c382efe9 | ||
|
3b8fcccfc7 | ||
|
d77f07bf04 | ||
|
bd46f1d203 | ||
|
338d3032a9 | ||
|
8590a4aaf7 | ||
|
77bc85593c | ||
|
e7f21364ce | ||
|
1808f8afd4 | ||
|
0ba39d002f | ||
|
1fae042d26 | ||
|
c3bc542e51 | ||
|
b8a2e7ee19 | ||
|
0527765eb3 | ||
|
7f49c06657 | ||
|
b0c0450c4c | ||
|
9fc6f5cae1 | ||
|
78d266f0ba | ||
|
3993c41dbf | ||
|
aaa41ccf27 | ||
|
953b02eea1 | ||
|
6c9756fc3a | ||
|
fad15caaba | ||
|
134424994e | ||
|
5d67b82409 | ||
|
07cb676dc1 | ||
|
cfc7b61398 | ||
|
501acec95e | ||
|
43540f5b38 | ||
|
2e9435f3cc | ||
|
b8e97d7a3c | ||
|
faeb610961 | ||
|
0dfc5aed76 | ||
|
8d7358b3b3 | ||
|
ce0eeb8457 | ||
|
65b49b18b3 | ||
|
4a423fdf88 | ||
|
9fb9c5ccb8 | ||
|
0c3bf6129d | ||
|
8c95f33c0a | ||
|
a3eed43115 | ||
|
8b1415488d | ||
|
b31c92e9d4 | ||
|
76159a7bcc | ||
|
f01cf519dc | ||
|
1edcacf955 | ||
|
3dd0f9245c | ||
|
117747708b | ||
|
31194be638 | ||
|
91f9172faf | ||
|
11396d7877 | ||
|
d503d912f3 | ||
|
c3c670b954 | ||
|
1fa987c518 | ||
|
d9fe29e9c7 | ||
|
f3af8fcafd | ||
|
17df897c32 | ||
|
a972faf0fd | ||
|
0d6766f621 | ||
|
77c436b99b | ||
|
f8e4e6e37f | ||
|
63c763c6a0 | ||
|
a4d968e4ec | ||
|
a7d5c496db | ||
|
4a82d77e0b | ||
|
3b9f472111 | ||
|
c657b1aae8 | ||
|
57997f980b | ||
|
bd51ce80f5 | ||
|
eccead0d74 | ||
|
e988349add | ||
|
4e017f1618 | ||
|
6353624986 | ||
|
8e17298694 | ||
|
d343b13668 | ||
|
c16aaa51ae | ||
|
40cee8a54c | ||
|
ac0a15df8a | ||
|
4b2f84448c | ||
|
07d67aacd0 | ||
|
36790e271f | ||
|
b685b8040a | ||
|
2397fb0e6c | ||
|
349b4118da | ||
|
2f69883b30 | ||
|
1680db0961 | ||
|
ded7f094e6 | ||
|
f0fe6d57fd | ||
|
fd0ccc1f0b | ||
|
7e2a6e77d1 | ||
|
ead2c1fc19 | ||
|
2c923b03ea | ||
|
5c2242422a | ||
|
523053315d | ||
|
1c79938bb1 | ||
|
487661919b | ||
|
a080c85cbc | ||
|
8df0bf44a8 | ||
|
b4728f6aa4 | ||
|
9ac120a557 | ||
|
0bb62e0381 | ||
|
513b3a5c4d | ||
|
79e132824a | ||
|
2c50c43290 | ||
|
6ab3093956 | ||
|
b2c2db0764 | ||
|
807bcc25a4 | ||
|
d1ec7125cf | ||
|
a6ae1210da | ||
|
973cf362fb | ||
|
ba1aa690ed | ||
|
248f51b290 | ||
|
4d682aa01d | ||
|
d0f6481cab | ||
|
7355d67a64 | ||
|
46a8b006f0 | ||
|
48c91151ad | ||
|
024ab8f28e | ||
|
2b4eb55d28 | ||
|
a8bb23f570 | ||
|
27b6436196 | ||
|
70aaf33082 | ||
|
8f95182392 | ||
|
c1ccfdd859 | ||
|
7aafac9448 | ||
|
8803721f3d | ||
|
d6c98866b9 | ||
|
45f8f61103 | ||
|
56e9b89199 | ||
|
91ee778665 | ||
|
4fd3ac376c | ||
|
6765efbd61 | ||
|
84ec13ca19 | ||
|
af41111458 | ||
|
2a2a034788 | ||
|
9b8d2d5ed5 | ||
|
21899e638b | ||
|
e81f4e9b7e | ||
|
a6133f34b7 | ||
|
b5c56d57f2 | ||
|
54403dd678 | ||
|
496ef86339 | ||
|
d71e2fcfa8 | ||
|
c4ed7bc415 | ||
|
0f6909a165 | ||
|
91be466d29 | ||
|
b181c6baf5 | ||
|
412ffeb06d | ||
|
1b7f41ca6f | ||
|
dbcdc904b9 | ||
|
f23f38a492 | ||
|
b1e5d95841 | ||
|
b61b784187 | ||
|
1aa392f29b | ||
|
5046d874bc | ||
|
e721482e57 | ||
|
63c9a78b06 | ||
|
798d2ac1d9 | ||
|
7496404438 | ||
|
ef91648d8f | ||
|
456aa65d17 | ||
|
fd25f80257 | ||
|
1ca7dea205 |
528
.all-contributorsrc
Normal file
@ -0,0 +1,528 @@
|
||||
{
|
||||
"projectName": "gotty",
|
||||
"projectOwner": "sorenisanerd",
|
||||
"repoType": "github",
|
||||
"repoHost": "https://github.com",
|
||||
"files": [
|
||||
"README.md"
|
||||
],
|
||||
"imageSize": 100,
|
||||
"commit": true,
|
||||
"commitConvention": "none",
|
||||
"contributors": [
|
||||
{
|
||||
"login": "yudai",
|
||||
"name": "Iwasaki Yudai",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/33192?v=4",
|
||||
"profile": "https://yudai.arielworks.com/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "sorenisanerd",
|
||||
"name": "Soren L. Hansen",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/160090?v=4",
|
||||
"profile": "http://linux2go.dk/",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "uovobw",
|
||||
"name": "Andrea Lusuardi",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1194751?v=4",
|
||||
"profile": "https://github.com/uovobw",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "moul",
|
||||
"name": "Manfred Touron",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/94029?v=4",
|
||||
"profile": "https://github.com/moul",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "svanellewee",
|
||||
"name": "Stephan",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1567439?v=4",
|
||||
"profile": "https://github.com/svanellewee",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "QuentinPerez",
|
||||
"name": "Quentin Perez",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3081204?v=4",
|
||||
"profile": "https://fr.linkedin.com/in/quentinperez",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "jizhilong",
|
||||
"name": "jzl",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/816618?v=4",
|
||||
"profile": "https://github.com/jizhilong",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "fazalmajid",
|
||||
"name": "Fazal Majid",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/331198?v=4",
|
||||
"profile": "https://majid.info/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Immortalin",
|
||||
"name": "Immortalin",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/7126128?v=4",
|
||||
"profile": "https://narrationbox.com/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "freakhill",
|
||||
"name": "freakhill",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/916582?v=4",
|
||||
"profile": "https://github.com/freakhill",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "0xflotus",
|
||||
"name": "0xflotus",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/26602940?v=4",
|
||||
"profile": "https://github.com/0xflotus",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "skeltoac",
|
||||
"name": "Andy Skelton",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/52292?v=4",
|
||||
"profile": "https://andy.blog/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "artdevjs",
|
||||
"name": "Artem Medvedev",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/7567983?v=4",
|
||||
"profile": "https://twitter.com/artdevjs",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "blakejennings",
|
||||
"name": "Blake Jennings",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1976331?v=4",
|
||||
"profile": "https://github.com/blakejennings",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "jensenbox",
|
||||
"name": "Christian Jensen",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/189265?v=4",
|
||||
"profile": "https://github.com/jensenbox",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "TechWilk",
|
||||
"name": "Christopher Wilkinson",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/9367803?v=4",
|
||||
"profile": "https://wilk.tech/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "RealCyGuy",
|
||||
"name": "Cyrus",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/54488650?v=4",
|
||||
"profile": "https://github.com/RealCyGuy",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "dehorsley",
|
||||
"name": "David Horsley",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3401668?v=4",
|
||||
"profile": "https://github.com/dehorsley",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Jason-Cooke",
|
||||
"name": "Jason Cooke",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/5185660?v=4",
|
||||
"profile": "https://jasoncooke.dev/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "DenKoren",
|
||||
"name": "Denis Korenevskiy",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3419381?v=4",
|
||||
"profile": "https://github.com/DenKoren",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "stucchimax",
|
||||
"name": "Massimiliano Stucchi",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1331438?v=4",
|
||||
"profile": "https://www.stucchi.ch/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Felixoid",
|
||||
"name": "Mikhail f. Shiryaev",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3025537?v=4",
|
||||
"profile": "https://www.linkedin.com/in/felixoid/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "guywithnose",
|
||||
"name": "Robert Bittle",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1059169?v=4",
|
||||
"profile": "https://github.com/guywithnose",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "sehaas",
|
||||
"name": "sebastian haas",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/283482?v=4",
|
||||
"profile": "https://deebas.com/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "shoz",
|
||||
"name": "shoji",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/225194?v=4",
|
||||
"profile": "https://github.com/shoz",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "tsl0922",
|
||||
"name": "Shuanglei Tao",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1680515?v=4",
|
||||
"profile": "https://github.com/tsl0922",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "gitter-badger",
|
||||
"name": "The Gitter Badger",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/8518239?v=4",
|
||||
"profile": "https://gitter.im/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "xinsnake",
|
||||
"name": "Jacob Zhou",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1287677?v=4",
|
||||
"profile": "https://github.com/xinsnake",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "zyfdegh",
|
||||
"name": "zyfdegh",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/7880217?v=4",
|
||||
"profile": "https://github.com/zyfdegh",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "fredster33",
|
||||
"name": "fredster33",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/64927044?v=4",
|
||||
"profile": "https://github.com/fredster33",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "mattn",
|
||||
"name": "mattn",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/10111?v=4",
|
||||
"profile": "https://mattn.kaoriya.net/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "shingt",
|
||||
"name": "Shinichi Goto",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1391330?v=4",
|
||||
"profile": "https://www.shingt.com/",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ygit",
|
||||
"name": "ygit",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/8512357?v=4",
|
||||
"profile": "https://twitter.com/_yogeshsingh",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "nephaste",
|
||||
"name": "Stéphane",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/3392684?v=4",
|
||||
"profile": "http://forum.cachem.fr/viewforum.php?f=21",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "prusnak",
|
||||
"name": "Pavol Rusnak",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/42201?v=4",
|
||||
"profile": "https://rusnak.io/",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "devanlai",
|
||||
"name": "Devan Lai",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1348448?v=4",
|
||||
"profile": "https://github.com/devanlai",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "jkandasa",
|
||||
"name": "Jeeva Kandasamy",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1004403?v=4",
|
||||
"profile": "https://github.com/jkandasa",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "hardliner66",
|
||||
"name": "Steve Biedermann",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/2937272?v=4",
|
||||
"profile": "https://twitch.tv/iamhardliner",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "xgdgsc",
|
||||
"name": "xgdgsc",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1189869?v=4",
|
||||
"profile": "https://github.com/xgdgsc",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "flechaig",
|
||||
"name": "flechaig",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/10887132?v=4",
|
||||
"profile": "https://github.com/flechaig",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Fan-SJ",
|
||||
"name": "Fan-SJ",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/49977708?v=4",
|
||||
"profile": "https://github.com/Fan-SJ",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "dmartin",
|
||||
"name": "Dustin Martin",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1657652?v=4",
|
||||
"profile": "https://github.com/dmartin",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ahmetb",
|
||||
"name": "Ahmet Alp Balkan",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/159209?v=4",
|
||||
"profile": "https://ahmet.dev/",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "CoconutMacaroon",
|
||||
"name": "CoconutMacaroon",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/45187468?v=4",
|
||||
"profile": "https://github.com/CoconutMacaroon",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "DannyBen",
|
||||
"name": "Danny Ben Shitrit",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/2405099?v=4",
|
||||
"profile": "https://github.dannyben.com/",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "George-NG",
|
||||
"name": "George-NG",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/28577165?v=4",
|
||||
"profile": "https://github.com/George-NG",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ghthor",
|
||||
"name": "Will Owens",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/160298?v=4",
|
||||
"profile": "https://github.com/ghthor",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "jpillora",
|
||||
"name": "Jaime Pillora",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/633843?v=4",
|
||||
"profile": "https://jpillora.com/",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "kaisawind",
|
||||
"name": "kaisawind",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/4010613?v=4",
|
||||
"profile": "https://github.com/kaisawind",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "linyinli",
|
||||
"name": "linyinli",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/42955482?v=4",
|
||||
"profile": "https://github.com/linyinli",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "LucaMarconato",
|
||||
"name": "LucaMarconato",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/2664412?v=4",
|
||||
"profile": "https://github.com/LucaMarconato",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "masterkain",
|
||||
"name": "Kain",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/12844?v=4",
|
||||
"profile": "https://audiobox.fm/",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Nexuist",
|
||||
"name": "Andi Andreas",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1498061?v=4",
|
||||
"profile": "http://duro.me/",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "qigj",
|
||||
"name": "qigj",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/56585735?v=4",
|
||||
"profile": "https://github.com/qigj",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "shuaiyy",
|
||||
"name": "shuaiyy",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/19821321?v=4",
|
||||
"profile": "https://github.com/shuaiyy",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "v20z",
|
||||
"name": "v20z",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/2884824?v=4",
|
||||
"profile": "https://github.com/v20z",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Yann-Qiu",
|
||||
"name": "Yanfeng Qiu",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/56961747?v=4",
|
||||
"profile": "https://github.com/Yann-Qiu",
|
||||
"contributions": [
|
||||
"bug"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7
|
||||
}
|
27
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# When file a bug report (see below for feature requests)
|
||||
|
||||
Please answer these quesions for a bug report. Thanks!
|
||||
|
||||
### What version of GoTTY are you using (`gotty --version`)?
|
||||
|
||||
|
||||
### What operating system and browser are you using?
|
||||
|
||||
|
||||
### What did you do?
|
||||
|
||||
If possible, please provide the command you ran.
|
||||
|
||||
|
||||
### What did you expect to see?
|
||||
|
||||
|
||||
### What did you see instead?
|
||||
|
||||
If possible, please provide the output of the command and your browser's console output.
|
||||
|
||||
|
||||
|
||||
# When file a new feature proposal
|
||||
|
||||
Please provide an actual usecase that requires your new feature.
|
49
.github/workflows/main.yaml
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
name: "Unit and Build Tests"
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
|
||||
jobs:
|
||||
bundle-up-to-date:
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.19
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
- run: "make clean"
|
||||
- run: "make assets"
|
||||
- name: "Make sure gotty.js bundle is up-to-date"
|
||||
run: "diffsize=$(git diff bindata/static/js/gotty.js | wc -l); test $diffsize == 0"
|
||||
|
||||
|
||||
cross-compile-test:
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.19
|
||||
|
||||
- name: "Build & test"
|
||||
run: "make tools test cross_compile"
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: binaries
|
||||
path: builds/pkg/*/gotty
|
42
.github/workflows/pre-release.yaml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
name: "pre-release"
|
||||
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
jobs:
|
||||
pre-release-docker:
|
||||
name: "Pre Release Docker"
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
-
|
||||
name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: ${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=sha,format=long
|
||||
type=sha
|
||||
type=semver,pattern=v{{major}}.{{minor}}.{{patch}}
|
||||
type=semver,pattern=v{{major}}.{{minor}}
|
||||
type=semver,pattern=v{{major}}
|
||||
type=ref,event=tag
|
||||
type=ref,event=branch
|
||||
|
||||
- uses: docker/setup-qemu-action@v2
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: docker/login-action@v2
|
||||
with:
|
||||
username: "${{ secrets.DOCKER_HUB_USER }}"
|
||||
password: "${{ secrets.DOCKER_HUB_TOKEN }}"
|
||||
- name: "Build and push docker image"
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
30
.github/workflows/quick-build.yaml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: "Quick build test"
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
|
||||
jobs:
|
||||
quick-build-test:
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.19
|
||||
|
||||
- name: "Build"
|
||||
run: "touch bindata/* bindata/*/* ; make"
|
||||
|
||||
- name: Upload linux/amd64 artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: gotty-linux-amd64
|
||||
path: gotty
|
40
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
name: "tagged-release"
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
tagged-release:
|
||||
name: "Tagged Release"
|
||||
runs-on: "ubuntu-latest"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.19
|
||||
|
||||
- name: "Build & test"
|
||||
run: "make tools test release-artifacts"
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: binaries
|
||||
path: builds/pkg/*/gotty
|
||||
|
||||
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
prerelease: false
|
||||
draft: true
|
||||
files: |
|
||||
LICENSE
|
||||
builds/dist/*
|
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
gotty
|
||||
bindata
|
||||
builds
|
||||
js/dist
|
||||
js/node_modules/*
|
||||
|
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "libapps"]
|
||||
path = libapps
|
||||
url = https://chromium.googlesource.com/apps/libapps
|
9
.mailmap
Normal file
@ -0,0 +1,9 @@
|
||||
# 'git shortlog --help' and look for mailmap for the format of each line
|
||||
|
||||
# Email consolidation:
|
||||
# <Preferred address in AUTHORS> <other alias used by same author>
|
||||
|
||||
|
||||
# Name consolidation:
|
||||
# Preferred author spelling <preferred email>
|
||||
Søren L. Hansen <sorenisanerd@gmail.com>
|
5
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"amodio.tsl-problem-matcher"
|
||||
]
|
||||
}
|
27
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch GoTTY",
|
||||
"type": "go",
|
||||
"buildFlags": "-tags=dev",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "${workspaceFolder}",
|
||||
"args": ["-a", "127.0.0.1", "-w", "${env:SHELL}"]
|
||||
},
|
||||
{
|
||||
"name": "Launch Chrome",
|
||||
"type": "chrome",
|
||||
"url": "http://127.0.0.1:8080",
|
||||
"webRoot": "${workspaceFolder}/js",
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/**/*.js",
|
||||
"!**/node_modules/**"
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
16
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "webpack watch",
|
||||
"type": "shell",
|
||||
"command": "cd ${workspaceFolder}/js;DEV=1 npx webpack --watch --mode=development",
|
||||
"problemMatcher": [
|
||||
"$ts-webpack-watch"
|
||||
],
|
||||
"isBackground": true
|
||||
}
|
||||
]
|
||||
}
|
44
CONTRIBUTING.md
Normal file
@ -0,0 +1,44 @@
|
||||
# How to contribute
|
||||
|
||||
GoTTY is MIT licensed and accepts contributions via GitHub pull requests. We also accepts feature requests on GitHub issues.
|
||||
|
||||
## Reporting a bug
|
||||
|
||||
Reporting a bug is always welcome and one of the best ways to contribute. A good bug report helps the developers to improve the product much easier. We therefore would like to ask you to fill out the quesions on the issue template as much as possible. That helps us to figure out what's happening and discover the root cause.
|
||||
|
||||
|
||||
## Requesting a new feature
|
||||
|
||||
When you find that GoTTY cannot fullfill your requirements because of lack of ability, you may want to open a new feature request. In that case, please file a new issue with your usecase and requirements.
|
||||
|
||||
|
||||
## Opening a pull request
|
||||
|
||||
### Code Style
|
||||
|
||||
Please run `go fmt` on your Go code and make sure that your commits are organized for each logical change and your commit messages are in proper format (see below).
|
||||
|
||||
[Go's official code style guide](https://github.com/golang/go/wiki/CodeReviewComments) is also helpful.
|
||||
|
||||
### Format of the commit message
|
||||
|
||||
When you write a commit message, we recommend include following information to make review easier and keep the history cleaerer.
|
||||
|
||||
* What is the change
|
||||
* The reason for the change
|
||||
|
||||
The following is an example:
|
||||
|
||||
```
|
||||
Add something new to existing package
|
||||
|
||||
Since the existing function lacks that mechanism for some purpose,
|
||||
this commit adds a new structure to provide it.
|
||||
```
|
||||
|
||||
When your pull request is to add a new feature, we recommend add an actual usecase so that we can discuss the best way to achive your requirement. Opening a proposal issue in advance is another good way to start discussion of new features.
|
||||
|
||||
|
||||
## Contact
|
||||
|
||||
If you have a trivial question about GoTTY for a bug or new feature, you can contact @sorenisanerd on Twitter (unfortunately, I cannot provide support on GoTTY though).
|
20
Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
FROM node:16 as js-build
|
||||
WORKDIR /gotty
|
||||
COPY js /gotty/js
|
||||
COPY Makefile /gotty/
|
||||
RUN make bindata/static/js/gotty.js.map
|
||||
|
||||
FROM golang:1.20 as go-build
|
||||
WORKDIR /gotty
|
||||
COPY . /gotty
|
||||
COPY --from=js-build /gotty/js/node_modules /gotty/js/node_modules
|
||||
COPY --from=js-build /gotty/bindata/static/js /gotty/bindata/static/js
|
||||
RUN CGO_ENABLED=0 make
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk update && \
|
||||
apk upgrade && \
|
||||
apk --no-cache add ca-certificates bash
|
||||
WORKDIR /root
|
||||
COPY --from=go-build /gotty/gotty /usr/bin/
|
||||
CMD ["gotty", "-w", "bash"]
|
57
Godeps/Godeps.json
generated
@ -1,57 +0,0 @@
|
||||
{
|
||||
"ImportPath": "github.com/yudai/gotty",
|
||||
"GoVersion": "go1.7",
|
||||
"GodepVersion": "v62",
|
||||
"Packages": [
|
||||
"./..."
|
||||
],
|
||||
"Deps": [
|
||||
{
|
||||
"ImportPath": "github.com/braintree/manners",
|
||||
"Comment": "0.4.0-6-g9e2a271",
|
||||
"Rev": "9e2a2714de21eb092ead2ef56d8c7a60d7928819"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/codegangsta/cli",
|
||||
"Comment": "1.2.0-139-g142e6cd",
|
||||
"Rev": "142e6cd241a4dfbf7f07a018f1f8225180018da4"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/elazarl/go-bindata-assetfs",
|
||||
"Rev": "d5cac425555ca5cf00694df246e04f05e6a55150"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fatih/structs",
|
||||
"Rev": "a9f7daa9c2729e97450c2da2feda19130a367d8f"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/gorilla/websocket",
|
||||
"Rev": "b6ab76f1fe9803ee1d59e7e5b2a797c1fe897ce5"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/hashicorp/go-multierror",
|
||||
"Rev": "56912fb08d85084aa318edcf2bba735b97cf35c5"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/kr/pty",
|
||||
"Comment": "release.r56-28-g5cf931e",
|
||||
"Rev": "5cf931ef8f76dccd0910001d74a58a7fca84a83d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/yudai/hcl",
|
||||
"Rev": "5fa2393b3552119bf33a69adb1402a1160cba23d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/yudai/hcl/hcl",
|
||||
"Rev": "5fa2393b3552119bf33a69adb1402a1160cba23d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/yudai/hcl/json",
|
||||
"Rev": "5fa2393b3552119bf33a69adb1402a1160cba23d"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/yudai/umutex",
|
||||
"Rev": "18216d265c6bc72c3bb0ad9c8103d47d530b7003"
|
||||
}
|
||||
]
|
||||
}
|
5
Godeps/Readme
generated
@ -1,5 +0,0 @@
|
||||
This directory tree is generated automatically by godep.
|
||||
|
||||
Please do not edit.
|
||||
|
||||
See https://github.com/tools/godep for more information.
|
622
LICENSE
@ -1,6 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Iwasaki Yudai
|
||||
Copyright (c) 2015-2017 Iwasaki Yudai
|
||||
Copyright (c) 2021-2022 Søren L. Hansen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@ -19,622 +20,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
=============================================================================
|
||||
|
||||
This software is built with following third party open source software.
|
||||
|
||||
|
||||
# golng/go
|
||||
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
# libapps/hterm
|
||||
|
||||
Copyright (c) 2014, Google Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Google Inc. nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
# odegangsta/cli
|
||||
|
||||
Copyright (C) 2013 Jeremy Saenz
|
||||
All Rights Reserved.
|
||||
|
||||
MIT LICENSE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
# jteeuwen/go-bindata
|
||||
|
||||
This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
|
||||
license. Its contents can be found at:
|
||||
http://creativecommons.org/publicdomain/zero/1.0
|
||||
|
||||
# elazarl/go-bindata-assetfs
|
||||
|
||||
Copyright (c) 2014, Elazar Leibovich
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
# gorilla/websocket
|
||||
|
||||
Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
# kr/pty
|
||||
|
||||
Copyright (c) 2011 Keith Rarick
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute,
|
||||
sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall
|
||||
be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
# krishnasrinivas/wetty
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Krishna Srinivas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
# braintree/manners
|
||||
|
||||
Copyright (c) 2014 Braintree, a division of PayPal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
# fatih/camelcase
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Fatih Arslan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
# fatih/structs
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Fatih Arslan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
# hashicorp/hcl
|
||||
|
||||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. “Contributor”
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. “Contributor Version”
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor’s Contribution.
|
||||
|
||||
1.3. “Contribution”
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. “Covered Software”
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. “Incompatible With Secondary Licenses”
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of version
|
||||
1.1 or earlier of the License, but not also under the terms of a
|
||||
Secondary License.
|
||||
|
||||
1.6. “Executable Form”
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. “Larger Work”
|
||||
|
||||
means a work that combines Covered Software with other material, in a separate
|
||||
file or files, that is not Covered Software.
|
||||
|
||||
1.8. “License”
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. “Licensable”
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether at the
|
||||
time of the initial grant or subsequently, any and all of the rights conveyed by
|
||||
this License.
|
||||
|
||||
1.10. “Modifications”
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to, deletion
|
||||
from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. “Patent Claims” of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method, process,
|
||||
and apparatus claims, in any patent Licensable by such Contributor that
|
||||
would be infringed, but for the grant of the License, by the making,
|
||||
using, selling, offering for sale, having made, import, or transfer of
|
||||
either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. “Secondary License”
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. “Source Code Form”
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. “You” (or “Your”)
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, “You” includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, “control” means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or as
|
||||
part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its Contributions
|
||||
or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution become
|
||||
effective for each Contribution on the date the Contributor first distributes
|
||||
such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under this
|
||||
License. No additional rights or licenses will be implied from the distribution
|
||||
or licensing of Covered Software under this License. Notwithstanding Section
|
||||
2.1(b) above, no patent license is granted by a Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party’s
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of its
|
||||
Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks, or
|
||||
logos of any Contributor (except as may be necessary to comply with the
|
||||
notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this License
|
||||
(see Section 10.2) or under the terms of a Secondary License (if permitted
|
||||
under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its Contributions
|
||||
are its original creation(s) or it has sufficient rights to grant the
|
||||
rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under applicable
|
||||
copyright doctrines of fair use, fair dealing, or other equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under the
|
||||
terms of this License. You must inform recipients that the Source Code Form
|
||||
of the Covered Software is governed by the terms of this License, and how
|
||||
they can obtain a copy of this License. You may not attempt to alter or
|
||||
restrict the recipients’ rights in the Source Code Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this License,
|
||||
or sublicense it under different terms, provided that the license for
|
||||
the Executable Form does not attempt to limit or alter the recipients’
|
||||
rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for the
|
||||
Covered Software. If the Larger Work is a combination of Covered Software
|
||||
with a work governed by one or more Secondary Licenses, and the Covered
|
||||
Software is not Incompatible With Secondary Licenses, this License permits
|
||||
You to additionally distribute such Covered Software under the terms of
|
||||
such Secondary License(s), so that the recipient of the Larger Work may, at
|
||||
their option, further distribute the Covered Software under the terms of
|
||||
either this License or such Secondary License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices (including
|
||||
copyright notices, patent notices, disclaimers of warranty, or limitations
|
||||
of liability) contained within the Source Code Form of the Covered
|
||||
Software, except that You may alter any license notices to the extent
|
||||
required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on behalf
|
||||
of any Contributor. You must make it absolutely clear that any such
|
||||
warranty, support, indemnity, or liability obligation is offered by You
|
||||
alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute, judicial
|
||||
order, or regulation then You must: (a) comply with the terms of this License
|
||||
to the maximum extent possible; and (b) describe the limitations and the code
|
||||
they affect. Such description must be placed in a text file included with all
|
||||
distributions of the Covered Software under this License. Except to the
|
||||
extent prohibited by statute or regulation, such description must be
|
||||
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing basis,
|
||||
if such Contributor fails to notify You of the non-compliance by some
|
||||
reasonable means prior to 60 days after You have come back into compliance.
|
||||
Moreover, Your grants from a particular Contributor are reinstated on an
|
||||
ongoing basis if such Contributor notifies You of the non-compliance by
|
||||
some reasonable means, this is the first time You have received notice of
|
||||
non-compliance with this License from such Contributor, and You become
|
||||
compliant prior to 30 days after Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions, counter-claims,
|
||||
and cross-claims) alleging that a Contributor Version directly or
|
||||
indirectly infringes any patent, then the rights granted to You by any and
|
||||
all Contributors for the Covered Software under Section 2.1 of this License
|
||||
shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an “as is” basis, without
|
||||
warranty of any kind, either expressed, implied, or statutory, including,
|
||||
without limitation, warranties that the Covered Software is free of defects,
|
||||
merchantable, fit for a particular purpose or non-infringing. The entire
|
||||
risk as to the quality and performance of the Covered Software is with You.
|
||||
Should any Covered Software prove defective in any respect, You (not any
|
||||
Contributor) assume the cost of any necessary servicing, repair, or
|
||||
correction. This disclaimer of warranty constitutes an essential part of this
|
||||
License. No use of any Covered Software is authorized under this License
|
||||
except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from such
|
||||
party’s negligence to the extent applicable law prohibits such limitation.
|
||||
Some jurisdictions do not allow the exclusion or limitation of incidental or
|
||||
consequential damages, so this exclusion and limitation may not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts of
|
||||
a jurisdiction where the defendant maintains its principal place of business
|
||||
and such litigation shall be governed by laws of that jurisdiction, without
|
||||
reference to its conflict-of-law provisions. Nothing in this Section shall
|
||||
prevent a party’s ability to bring cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject matter
|
||||
hereof. If any provision of this License is held to be unenforceable, such
|
||||
provision shall be reformed only to the extent necessary to make it
|
||||
enforceable. Any law or regulation which provides that the language of a
|
||||
contract shall be construed against the drafter shall not be used to construe
|
||||
this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version of
|
||||
the License under which You originally received the Covered Software, or
|
||||
under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a modified
|
||||
version of this License if you rename the license and remove any
|
||||
references to the name of the license steward (except to note that such
|
||||
modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file, then
|
||||
You may include the notice in a location (such as a LICENSE file in a relevant
|
||||
directory) where a recipient would be likely to look for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - “Incompatible With Secondary Licenses” Notice
|
||||
|
||||
This Source Code Form is “Incompatible
|
||||
With Secondary Licenses”, as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
94
Makefile
@ -1,54 +1,92 @@
|
||||
OUTPUT_DIR = ./builds
|
||||
GIT_COMMIT = `git rev-parse HEAD | cut -c1-7`
|
||||
VERSION = $(shell git describe --tags)
|
||||
BUILD_OPTIONS = -ldflags "-X main.Version=$(VERSION)"
|
||||
|
||||
gotty: app/resource.go main.go app/*.go
|
||||
godep go build
|
||||
ifeq ($(DEV), 1)
|
||||
BUILD_OPTIONS += -tags dev
|
||||
WEBPACK_MODE = development
|
||||
else
|
||||
WEBPACK_MODE = production
|
||||
endif
|
||||
|
||||
resource: app/resource.go
|
||||
export CGO_ENABLED=0
|
||||
|
||||
app/resource.go: bindata/static/js/hterm.js bindata/static/js/gotty.js bindata/static/index.html bindata/static/favicon.png
|
||||
go-bindata -prefix bindata -pkg app -ignore=\\.gitkeep -o app/resource.go bindata/...
|
||||
gofmt -w app/resource.go
|
||||
gotty: main.go assets server/*.go webtty/*.go backend/*.go Makefile
|
||||
go build ${BUILD_OPTIONS}
|
||||
|
||||
bindata:
|
||||
mkdir bindata
|
||||
docker:
|
||||
docker build . -t gotty-bash:$(VERSION)
|
||||
|
||||
bindata/static: bindata
|
||||
mkdir bindata/static
|
||||
.PHONY: all docker assets
|
||||
assets: bindata/static/js/gotty.js.map \
|
||||
bindata/static/js/gotty.js \
|
||||
bindata/static/index.html \
|
||||
bindata/static/icon.svg \
|
||||
bindata/static/favicon.ico \
|
||||
bindata/static/css/index.css \
|
||||
bindata/static/css/xterm.css \
|
||||
bindata/static/css/xterm_customize.css \
|
||||
bindata/static/manifest.json \
|
||||
bindata/static/icon_192.png
|
||||
|
||||
bindata/static/index.html: bindata/static resources/index.html
|
||||
cp resources/index.html bindata/static/index.html
|
||||
all: gotty
|
||||
|
||||
bindata/static/favicon.png: bindata/static resources/favicon.png
|
||||
cp resources/favicon.png bindata/static/favicon.png
|
||||
bindata/static bindata/static/css bindata/static/js:
|
||||
mkdir -p $@
|
||||
|
||||
bindata/static/js: bindata/static
|
||||
mkdir -p bindata/static/js
|
||||
bindata/static/%: resources/% | bindata/static/css
|
||||
cp "$<" "$@"
|
||||
|
||||
bindata/static/js/hterm.js: bindata/static/js libapps/hterm/js/*.js
|
||||
cd libapps && \
|
||||
LIBDOT_SEARCH_PATH=`pwd` ./libdot/bin/concat.sh -i ./hterm/concat/hterm_all.concat -o ../bindata/static/js/hterm.js
|
||||
bindata/static/css/%.css: resources/%.css | bindata/static
|
||||
cp "$<" "$@"
|
||||
|
||||
bindata/static/js/gotty.js: bindata/static/js resources/gotty.js
|
||||
cp resources/gotty.js bindata/static/js/gotty.js
|
||||
bindata/static/css/xterm.css: js/node_modules/xterm/css/xterm.css | bindata/static
|
||||
cp "$<" "$@"
|
||||
|
||||
js/node_modules/xterm/dist/xterm.css:
|
||||
cd js && \
|
||||
npm install
|
||||
|
||||
bindata/static/js/gotty.js.map bindata/static/js/gotty.js: js/src/* | js/node_modules/webpack
|
||||
cd js && \
|
||||
npx webpack --mode=$(WEBPACK_MODE)
|
||||
|
||||
js/node_modules/webpack:
|
||||
cd js && \
|
||||
npm install
|
||||
|
||||
README-options:
|
||||
./gotty --help | sed '1,/GLOBAL OPTIONS/ d' > options.txt.tmp
|
||||
sed -f README.md.sed -i README.md
|
||||
rm options.txt.tmp
|
||||
|
||||
tools:
|
||||
go get github.com/tools/godep
|
||||
go get github.com/mitchellh/gox
|
||||
go get github.com/tcnksm/ghr
|
||||
go get github.com/jteeuwen/go-bindata/...
|
||||
go install github.com/mitchellh/gox@latest
|
||||
go install github.com/tcnksm/ghr@latest
|
||||
|
||||
test:
|
||||
if [ `go fmt $(go list ./... | grep -v /vendor/) | wc -l` -gt 0 ]; then echo "go fmt error"; exit 1; fi
|
||||
go test ./...
|
||||
|
||||
cross_compile:
|
||||
GOARM=5 gox -os="darwin linux freebsd netbsd openbsd" -arch="386 amd64 arm" -osarch="!darwin/arm" -output "${OUTPUT_DIR}/pkg/{{.OS}}_{{.Arch}}/{{.Dir}}"
|
||||
GOARM=5 gox -os="darwin linux freebsd netbsd openbsd solaris" -arch="386 amd64 arm arm64" -osarch="!darwin/386" -osarch="!darwin/arm" $(BUILD_OPTIONS) -output "${OUTPUT_DIR}/pkg/{{.OS}}_{{.Arch}}/{{.Dir}}"
|
||||
|
||||
targz:
|
||||
mkdir -p ${OUTPUT_DIR}/dist
|
||||
cd ${OUTPUT_DIR}/pkg/; for osarch in *; do (cd $$osarch; tar zcvf ../../dist/gotty_$$osarch.tar.gz ./*); done;
|
||||
cd ${OUTPUT_DIR}/pkg/; for osarch in *; do (cd $$osarch; tar zcvf ../../dist/gotty_${VERSION}_$$osarch.tar.gz ./*); done;
|
||||
|
||||
shasums:
|
||||
cd ${OUTPUT_DIR}/dist; sha256sum * > ./SHA256SUMS
|
||||
|
||||
release-artifacts: gotty cross_compile targz shasums
|
||||
|
||||
release:
|
||||
ghr --delete --prerelease -u yudai -r gotty pre-release ${OUTPUT_DIR}/dist
|
||||
ghr -draft ${VERSION} ${OUTPUT_DIR}/dist # -c ${GIT_COMMIT} --delete --prerelease -u sorenisanerd -r gotty ${VERSION}
|
||||
|
||||
clean:
|
||||
rm -fr gotty builds js/dist bindata/static js/node_modules
|
||||
|
||||
addcontributors:
|
||||
gh issue list -s all -L 1000 --json author -t "$$(echo '{{ range . }}{{ .author.login }}\n{{ end }}')" | sort | uniq | xargs -Ifoo all-contributors add foo bug --commitTemplate '<%= (newContributor ? "Add" : "Update") %> @<%= username %> as a contributor'
|
||||
gh pr list -s all -L 1000 --json author -t "$$(echo '{{ range . }}{{ .author.login }}\n{{ end }}')" | sort | uniq | xargs -Ifoo all-contributors add foo code --commitTemplate '<%= (newContributor ? "Add" : "Update") %> @<%= username %> as a contributor'
|
102
NEWS.md
Normal file
@ -0,0 +1,102 @@
|
||||
## 1.5.0 (2022-09-01)
|
||||
|
||||
* Add @ahmetb as a contributor ([276767a](https://github.com/sorenisanerd/gotty/commit/276767a))
|
||||
* Add @CoconutMacaroon as a contributor ([74c1318](https://github.com/sorenisanerd/gotty/commit/74c1318))
|
||||
* Add @DannyBen as a contributor ([fcfa161](https://github.com/sorenisanerd/gotty/commit/fcfa161))
|
||||
* Add @dmartin as a contributor ([6b2ae89](https://github.com/sorenisanerd/gotty/commit/6b2ae89))
|
||||
* Add @Fan-SJ as a contributor ([c2428c8](https://github.com/sorenisanerd/gotty/commit/c2428c8))
|
||||
* Add @flechaig as a contributor ([2c4004d](https://github.com/sorenisanerd/gotty/commit/2c4004d))
|
||||
* Add @George-NG as a contributor ([270ae45](https://github.com/sorenisanerd/gotty/commit/270ae45))
|
||||
* Add @ghthor as a contributor ([1a6bccd](https://github.com/sorenisanerd/gotty/commit/1a6bccd))
|
||||
* Add @jpillora as a contributor ([f52fbd7](https://github.com/sorenisanerd/gotty/commit/f52fbd7))
|
||||
* Add @kaisawind as a contributor ([accff3a](https://github.com/sorenisanerd/gotty/commit/accff3a))
|
||||
* Add @linyinli as a contributor ([8014af3](https://github.com/sorenisanerd/gotty/commit/8014af3))
|
||||
* Add @LucaMarconato as a contributor ([3bd9836](https://github.com/sorenisanerd/gotty/commit/3bd9836))
|
||||
* Add @masterkain as a contributor ([369e2f7](https://github.com/sorenisanerd/gotty/commit/369e2f7))
|
||||
* Add @Nexuist as a contributor ([ca691bc](https://github.com/sorenisanerd/gotty/commit/ca691bc))
|
||||
* Add @qigj as a contributor ([5a052e7](https://github.com/sorenisanerd/gotty/commit/5a052e7))
|
||||
* Add @shuaiyy as a contributor ([95e1bbd](https://github.com/sorenisanerd/gotty/commit/95e1bbd))
|
||||
* Add @v20z as a contributor ([d594bef](https://github.com/sorenisanerd/gotty/commit/d594bef))
|
||||
* Add @xgdgsc as a contributor ([c197990](https://github.com/sorenisanerd/gotty/commit/c197990))
|
||||
* Add @Yann-Qiu as a contributor ([7b994ec](https://github.com/sorenisanerd/gotty/commit/7b994ec))
|
||||
* Update @flechaig as a contributor ([9877e9c](https://github.com/sorenisanerd/gotty/commit/9877e9c))
|
||||
* Update @flechaig as a contributor ([e03ea9c](https://github.com/sorenisanerd/gotty/commit/e03ea9c))
|
||||
* Update @prusnak as a contributor ([3c45888](https://github.com/sorenisanerd/gotty/commit/3c45888))
|
||||
* Update @prusnak as a contributor ([8d7f5fc](https://github.com/sorenisanerd/gotty/commit/8d7f5fc))
|
||||
* Update @sorenisanerd as a contributor ([34f516b](https://github.com/sorenisanerd/gotty/commit/34f516b))
|
||||
* Update @sorenisanerd as a contributor ([89a04d1](https://github.com/sorenisanerd/gotty/commit/89a04d1))
|
||||
* Update @xgdgsc as a contributor ([b3c5d03](https://github.com/sorenisanerd/gotty/commit/b3c5d03))
|
||||
* Update @xgdgsc as a contributor ([09f7e95](https://github.com/sorenisanerd/gotty/commit/09f7e95))
|
||||
* Add make target to add contributors ([1bbfd5e](https://github.com/sorenisanerd/gotty/commit/1bbfd5e))
|
||||
* Add missing import "strings" ([d0e3ffb](https://github.com/sorenisanerd/gotty/commit/d0e3ffb))
|
||||
* add slash ([7706bf2](https://github.com/sorenisanerd/gotty/commit/7706bf2))
|
||||
* Always disable CGO ([7a96f37](https://github.com/sorenisanerd/gotty/commit/7a96f37)), closes [#39](https://github.com/sorenisanerd/gotty/issues/39)
|
||||
* Bump terser from 5.12.1 to 5.14.2 in /js ([3ae13e0](https://github.com/sorenisanerd/gotty/commit/3ae13e0))
|
||||
* Create a release when a new tag is pushed ([d8fe975](https://github.com/sorenisanerd/gotty/commit/d8fe975))
|
||||
* Ensure --quiet flag is honored ([7d431a7](https://github.com/sorenisanerd/gotty/commit/7d431a7)), closes [#45](https://github.com/sorenisanerd/gotty/issues/45)
|
||||
* Refresh dependencies, drop node-sass ([94e5873](https://github.com/sorenisanerd/gotty/commit/94e5873))
|
||||
* Run tests on pull requests ([316d5ff](https://github.com/sorenisanerd/gotty/commit/316d5ff))
|
||||
|
||||
|
||||
## 1.4.0 (2022-05-30)
|
||||
|
||||
* Add @hardliner66 as a contributor ([1ca998e](https://github.com/sorenisanerd/gotty/commit/1ca998e))
|
||||
* Add @jkandasa as a contributor ([cd23910](https://github.com/sorenisanerd/gotty/commit/cd23910))
|
||||
* Add backend tests ([603c650](https://github.com/sorenisanerd/gotty/commit/603c650))
|
||||
* Add generated data to git ([a9fbc07](https://github.com/sorenisanerd/gotty/commit/a9fbc07))
|
||||
* add quiet flag to disable logging ([4109b11](https://github.com/sorenisanerd/gotty/commit/4109b11))
|
||||
* Add references to @yudai ([bffd821](https://github.com/sorenisanerd/gotty/commit/bffd821)), closes [#8](https://github.com/sorenisanerd/gotty/issues/8)
|
||||
* Add rule to build gotty.js.map ([82c3acf](https://github.com/sorenisanerd/gotty/commit/82c3acf))
|
||||
* Apply font size and family in xterm ([f157dbe](https://github.com/sorenisanerd/gotty/commit/f157dbe)), closes [#21](https://github.com/sorenisanerd/gotty/issues/21)
|
||||
* Avoid HTTP 401 error on manifest.json due to CORS ([817b5c8](https://github.com/sorenisanerd/gotty/commit/817b5c8))
|
||||
* Bump browserslist from 4.16.4 to 4.16.6 in /js ([8deba62](https://github.com/sorenisanerd/gotty/commit/8deba62))
|
||||
* Disable arg passing by default ([5c8eb10](https://github.com/sorenisanerd/gotty/commit/5c8eb10)), closes [#17](https://github.com/sorenisanerd/gotty/issues/17)
|
||||
* Do not include ALL of bootstrap ([b63ea16](https://github.com/sorenisanerd/gotty/commit/b63ea16))
|
||||
* Ensure defaults for booleans is set correctly ([28f8e61](https://github.com/sorenisanerd/gotty/commit/28f8e61)), closes [#16](https://github.com/sorenisanerd/gotty/issues/16)
|
||||
* Fix existing tests ([d674aa1](https://github.com/sorenisanerd/gotty/commit/d674aa1)), closes [#13](https://github.com/sorenisanerd/gotty/issues/13)
|
||||
* Fix warnings from Markdown linter ([aa86a34](https://github.com/sorenisanerd/gotty/commit/aa86a34))
|
||||
* go fmt ([dcb153c](https://github.com/sorenisanerd/gotty/commit/dcb153c))
|
||||
* Improve webtty test coverage ([f61763f](https://github.com/sorenisanerd/gotty/commit/f61763f))
|
||||
* Make client request base64 encoding ([dd3603c](https://github.com/sorenisanerd/gotty/commit/dd3603c))
|
||||
* Make sure we read the full message ([1eed97f](https://github.com/sorenisanerd/gotty/commit/1eed97f))
|
||||
* Publish artifacts on push to master ([6c62ab7](https://github.com/sorenisanerd/gotty/commit/6c62ab7))
|
||||
* Remove hterm ([163fd05](https://github.com/sorenisanerd/gotty/commit/163fd05))
|
||||
* Run tests on push ([55674f1](https://github.com/sorenisanerd/gotty/commit/55674f1))
|
||||
* Run tests on push to all branches ([679a324](https://github.com/sorenisanerd/gotty/commit/679a324))
|
||||
* update go version in Dockerfile ([fd2fb99](https://github.com/sorenisanerd/gotty/commit/fd2fb99))
|
||||
* Update js dependencies ([26fc412](https://github.com/sorenisanerd/gotty/commit/26fc412))
|
||||
* Update xterm.js and other js libs ([81afdc7](https://github.com/sorenisanerd/gotty/commit/81afdc7)), closes [#18](https://github.com/sorenisanerd/gotty/issues/18)
|
||||
* Use bootstrap components for up- and downloads ([7f05f2f](https://github.com/sorenisanerd/gotty/commit/7f05f2f))
|
||||
* Use Go's built-in embed mechanism ([f66f0d0](https://github.com/sorenisanerd/gotty/commit/f66f0d0)), closes [#7](https://github.com/sorenisanerd/gotty/issues/7)
|
||||
* feat(zmodem): Allow file uploads/downloads ([782991c](https://github.com/sorenisanerd/gotty/commit/782991c))
|
||||
|
||||
|
||||
|
||||
## v1.3.0
|
||||
|
||||
* Links in the tty are now clickable.
|
||||
* Use WebGL for rendering by default.
|
||||
* Ensure authentication (TLS or Basic auth) remain enabled even if some of the options are only given in config files Thanks, @devanlai!
|
||||
* Fix typo in README.md Thanks, @prusnak!
|
||||
* Add arm64/Linux build. Thanks for the suggestion, @nephaste!
|
||||
|
||||
## v1.2.0
|
||||
|
||||
* Pass BUILD\_OPTIONS to gox, too, so release artifacts have version info included.
|
||||
* Update xterm.js 2.7.0 => 4.11.0
|
||||
* Lots of clean up.
|
||||
|
||||
## v1.1.0
|
||||
|
||||
* Today I learned about Go's handling of versions, so re-releasing 2.1.0 as 1.1.0.
|
||||
* Added path option. Thanks, @apatil!
|
||||
|
||||
## v2.1.0 (whoops)
|
||||
|
||||
* Use Go modules and update cli module import path. Thanks, @svanellewee!
|
||||
* Fix typos. Thanks, @0xflotus, @RealCyGuy, @ygit, @Jason-Cooke and @fredster33!
|
||||
* Fix printing of ipv6 addresses. Thanks, @Felixoid!
|
||||
* Add Progressive Web App support. Thanks, @sehaas!
|
||||
* Add instructions for GNU screen. Thanks, @Immortalin!
|
||||
* Add Solaris support. Thanks, @fazalmajid!
|
||||
* New maintainer: @sorenisanerd
|
220
README.md
@ -1,40 +1,44 @@
|
||||
#  GoTTY - Share your terminal as a web application
|
||||
#  GoTTY - Share your terminal as a web application
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
[](#contributors-)
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
|
||||
[][release]
|
||||
[][wercker]
|
||||
[][release]
|
||||
[][license]
|
||||
[][gitter]
|
||||
[][twitch]
|
||||
|
||||
[release]: https://github.com/yudai/gotty/releases
|
||||
[wercker]: https://app.wercker.com/project/bykey/03b91f441bebeda34f80e09a9f14126f
|
||||
[license]: https://github.com/yudai/gotty/blob/master/LICENSE
|
||||
[gitter]: https://gitter.im/yudai/gotty?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
||||
[release]: https://github.com/sorenisanerd/gotty/releases
|
||||
[license]: https://github.com/sorenisanerd/gotty/blob/master/LICENSE
|
||||
[twitch]: https://twitch.tv/sorencodes
|
||||
|
||||
GoTTY is a simple command line tool that turns your CLI tools into web applications.
|
||||
|
||||

|
||||
[Original work](https://github.com/yudai/gotty) by [Iwasaki Yudai](https://github.com/yudai). There would be no GoTTY without him. ❤️
|
||||
|
||||

|
||||
|
||||
# Installation
|
||||
|
||||
Download the latest binary file from the [Releases](https://github.com/yudai/gotty/releases) page.
|
||||
## From release page
|
||||
|
||||
(`darwin_amd64.tar.gz` is for Mac OS X users)
|
||||
You can download the latest stable binary file from the [Releases](https://github.com/sorenisanerd/gotty/releases) page. Note that the release marked `Pre-release` is built for testing purpose, which can include unstable or breaking changes. Download a release marked [Latest release](https://github.com/sorenisanerd/gotty/releases/latest) for a stable build.
|
||||
|
||||
(Files named with `darwin_amd64` are for Mac OS X users)
|
||||
|
||||
## Homebrew Installation
|
||||
|
||||
You can install GoTTY with [Homebrew](http://brew.sh/) as well.
|
||||
|
||||
```sh
|
||||
$ brew tap yudai/gotty
|
||||
$ brew install gotty
|
||||
$ brew install sorenisanerd/gotty/gotty
|
||||
```
|
||||
|
||||
## `go get` Installation
|
||||
## `go get` Installation (Development)
|
||||
|
||||
If you have a Go language environment, you can install GoTTY with the `go get` command.
|
||||
If you have a Go language environment, you can install GoTTY with the `go get` command. However, this command builds a binary file from the latest master branch, which can include unstable or breaking changes. GoTTY requires go1.9 or later.
|
||||
|
||||
```sh
|
||||
$ go get github.com/yudai/gotty
|
||||
$ go get github.com/sorenisanerd/gotty
|
||||
```
|
||||
|
||||
# Usage
|
||||
@ -48,33 +52,39 @@ Run `gotty` with your preferred command as its arguments (e.g. `gotty top`).
|
||||
By default, GoTTY starts a web server at port 8080. Open the URL on your web browser and you can see the running command as if it were running on your terminal.
|
||||
|
||||
## Options
|
||||
|
||||
```sh
|
||||
--address value, -a value IP address to listen (default: "0.0.0.0") [$GOTTY_ADDRESS]
|
||||
--port value, -p value Port number to liten (default: "8080") [$GOTTY_PORT]
|
||||
--path value, -m value Base path (default: "/") [$GOTTY_PATH]
|
||||
--permit-write, -w Permit clients to write to the TTY (BE CAREFUL) (default: false) [$GOTTY_PERMIT_WRITE]
|
||||
--credential value, -c value Credential for Basic Authentication (ex: user:pass, default disabled) [$GOTTY_CREDENTIAL]
|
||||
--random-url, -r Add a random string to the URL (default: false) [$GOTTY_RANDOM_URL]
|
||||
--random-url-length value Random URL length (default: 8) [$GOTTY_RANDOM_URL_LENGTH]
|
||||
--tls, -t Enable TLS/SSL (default: false) [$GOTTY_TLS]
|
||||
--tls-crt value TLS/SSL certificate file path (default: "~/.gotty.crt") [$GOTTY_TLS_CRT]
|
||||
--tls-key value TLS/SSL key file path (default: "~/.gotty.key") [$GOTTY_TLS_KEY]
|
||||
--tls-ca-crt value TLS/SSL CA certificate file for client certifications (default: "~/.gotty.ca.crt") [$GOTTY_TLS_CA_CRT]
|
||||
--index value Custom index.html file [$GOTTY_INDEX]
|
||||
--title-format value Title format of browser window (default: "{{ .command }}@{{ .hostname }}") [$GOTTY_TITLE_FORMAT]
|
||||
--reconnect Enable reconnection (default: false) [$GOTTY_RECONNECT]
|
||||
--reconnect-time value Time to reconnect (default: 10) [$GOTTY_RECONNECT_TIME]
|
||||
--max-connection value Maximum connection to gotty (default: 0) [$GOTTY_MAX_CONNECTION]
|
||||
--once Accept only one client and exit on disconnection (default: false) [$GOTTY_ONCE]
|
||||
--timeout value Timeout seconds for waiting a client(0 to disable) (default: 0) [$GOTTY_TIMEOUT]
|
||||
--permit-arguments Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB) (default: false) [$GOTTY_PERMIT_ARGUMENTS]
|
||||
--width value Static width of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_WIDTH]
|
||||
--height value Static height of the screen, 0(default) means dynamically resize (default: 0) [$GOTTY_HEIGHT]
|
||||
--ws-origin value A regular expression that matches origin URLs to be accepted by WebSocket. No cross origin requests are acceptable by default [$GOTTY_WS_ORIGIN]
|
||||
--ws-query-args value Querystring arguments to append to the websocket instantiation [$GOTTY_WS_QUERY_ARGS]
|
||||
--enable-webgl Enable WebGL renderer (default: true) [$GOTTY_ENABLE_WEBGL]
|
||||
--close-signal value Signal sent to the command process when gotty close it (default: SIGHUP) (default: 1) [$GOTTY_CLOSE_SIGNAL]
|
||||
--close-timeout value Time in seconds to force kill process after client is disconnected (default: -1) (default: -1) [$GOTTY_CLOSE_TIMEOUT]
|
||||
--config value Config file path (default: "~/.gotty") [$GOTTY_CONFIG]
|
||||
--help, -h show help (default: false)
|
||||
--version, -v print the version (default: false)
|
||||
```
|
||||
--address, -a IP address to listen [$GOTTY_ADDRESS]
|
||||
--port, -p "8080" Port number to listen [$GOTTY_PORT]
|
||||
--permit-write, -w Permit clients to write to the TTY (BE CAREFUL) [$GOTTY_PERMIT_WRITE]
|
||||
--credential, -c Credential for Basic Authentication (ex: user:pass, default disabled) [$GOTTY_CREDENTIAL]
|
||||
--random-url, -r Add a random string to the URL [$GOTTY_RANDOM_URL]
|
||||
--random-url-length "8" Random URL length [$GOTTY_RANDOM_URL_LENGTH]
|
||||
--tls, -t Enable TLS/SSL [$GOTTY_TLS]
|
||||
--tls-crt "~/.gotty.crt" TLS/SSL certificate file path [$GOTTY_TLS_CRT]
|
||||
--tls-key "~/.gotty.key" TLS/SSL key file path [$GOTTY_TLS_KEY]
|
||||
--tls-ca-crt "~/.gotty.ca.crt" TLS/SSL CA certificate file for client certifications [$GOTTY_TLS_CA_CRT]
|
||||
--index Custom index.html file [$GOTTY_INDEX]
|
||||
--title-format "GoTTY - {{ .Command }} ({{ .Hostname }})" Title format of browser window [$GOTTY_TITLE_FORMAT]
|
||||
--reconnect Enable reconnection [$GOTTY_RECONNECT]
|
||||
--reconnect-time "10" Time to reconnect [$GOTTY_RECONNECT_TIME]
|
||||
--timeout "0" Timeout seconds for waiting a client (0 to disable) [$GOTTY_TIMEOUT]
|
||||
--once Accept only one client and exit on disconnection [$GOTTY_ONCE]
|
||||
--permit-arguments Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB) [$GOTTY_PERMIT_ARGUMENTS]
|
||||
--close-signal "1" Signal sent to the command process when gotty close it (default: SIGHUP) [$GOTTY_CLOSE_SIGNAL]
|
||||
--config "~/.gotty" Config file path [$GOTTY_CONFIG]
|
||||
--version, -v print the version
|
||||
```
|
||||
|
||||
### Config File
|
||||
|
||||
You can customize default options and your terminal (hterm) by providing a config file to the `gotty` command. GoTTY loads a profile file at `~/.gotty` by default when it exists.
|
||||
You can customize default options and your terminal by providing a config file to the `gotty` command. GoTTY loads a profile file at `~/.gotty` by default when it exists.
|
||||
|
||||
```
|
||||
// Listen at port 9000 by default
|
||||
@ -83,23 +93,17 @@ port = "9000"
|
||||
// Enable TSL/SSL by default
|
||||
enable_tls = true
|
||||
|
||||
// hterm preferences
|
||||
// Smaller font and a little bit bluer background color
|
||||
preferences {
|
||||
font_size = 5,
|
||||
background_color = "rgb(16, 16, 32)"
|
||||
}
|
||||
```
|
||||
|
||||
See the [`.gotty`](https://github.com/yudai/gotty/blob/master/.gotty) file in this repository for the list of configuration options.
|
||||
See the [`.gotty`](https://github.com/sorenisanerd/gotty/blob/master/.gotty) file in this repository for the list of configuration options.
|
||||
|
||||
### Security Options
|
||||
|
||||
By default, GoTTY doesn't allow clients to send any keystrokes or commands except terminal window resizing. When you want to permit clients to write input to the TTY, add the `-w` option. However, accepting input from remote clients is dangerous for most commands. When you need interaction with the TTY for some reasons, consider starting GoTTY with tmux or GNU Screen and run your command on it (see "Sharing with Multiple Clients" section for detail).
|
||||
|
||||
To restrict client access, you can use the `-c` option to enable the basic authentication. With this option, clients need to input the specified username and password to connect to the GoTTY server. Note that the credentical will be transmitted between the server and clients in plain text. For more strict authentication, consider the SSL/TLS client certificate authentication described below.
|
||||
To restrict client access, you can use the `-c` option to enable the basic authentication. With this option, clients need to input the specified username and password to connect to the GoTTY server. Note that the credentials will be transmitted between the server and clients in plain text. For more strict authentication, consider the SSL/TLS client certificate authentication described below.
|
||||
|
||||
The `-r` option is a little bit casualer way to restrict access. With this option, GoTTY generates a random URL so that only people who know the URL can get access to the server.
|
||||
The `-r` option is a little bit more casual way to restrict access. With this option, GoTTY generates a random URL so that only people who know the URL can get access to the server.
|
||||
|
||||
All traffic between the server and clients are NOT encrypted by default. When you send secret information through GoTTY, we strongly recommend you use the `-t` option which enables TLS/SSL on the session. By default, GoTTY loads the crt and key files placed at `~/.gotty.crt` and `~/.gotty.key`. You can overwrite these file paths with the `--tls-crt` and `--tls-key` options. When you need to generate a self-signed certification file, you can use the `openssl` command.
|
||||
|
||||
@ -114,7 +118,9 @@ For additional security, you can use the SSL/TLS client certificate authenticati
|
||||
## Sharing with Multiple Clients
|
||||
|
||||
GoTTY starts a new process with the given command when a new client connects to the server. This means users cannot share a single terminal with others by default. However, you can use terminal multiplexers for sharing a single process with multiple clients.
|
||||
|
||||
### Screen
|
||||
After installing GNU screen, start a new session with `screen -S name-for-session` and connect to it with gotty in another terminal window/tab through `screen -x name-for-session`. All commands and activities being done in the first terminal tab/window will now be broadcasted by gotty.
|
||||
### Tmux
|
||||
For example, you can start a new tmux session named `gotty` with `top` command by the command below.
|
||||
|
||||
```sh
|
||||
@ -148,26 +154,13 @@ $ gotty -w docker run -it --rm busybox
|
||||
|
||||
## Development
|
||||
|
||||
You can build a binary using the following commands. Windows is not supported now.
|
||||
You can build a binary by simply running `make`. go1.16 is required.
|
||||
|
||||
```sh
|
||||
# Install tools
|
||||
go get github.com/jteeuwen/go-bindata/...
|
||||
go get github.com/tools/godep
|
||||
|
||||
# Checkout hterm
|
||||
git submodule sync && git submodule update --init --recursive
|
||||
|
||||
# Restore libraries in Godeps
|
||||
godep restore
|
||||
|
||||
# Build
|
||||
make
|
||||
```
|
||||
To build the frontend part (JS files and other static files), you need `npm`.
|
||||
|
||||
## Architecture
|
||||
|
||||
GoTTY uses [hterm](https://groups.google.com/a/chromium.org/forum/#!forum/chromium-hterm) to run a JavaScript based terminal on web browsers. GoTTY itself provides a websocket server that simply relays output from the TTY to clients and receives input from clients and forwards it to the TTY. This hterm + websocket idea is inspired by [Wetty](https://github.com/krishnasrinivas/wetty).
|
||||
GoTTY uses [xterm.js](https://xtermjs.org/) to run a JavaScript based terminal on web browsers. GoTTY itself provides a websocket server that simply relays output from the TTY to clients and receives input from clients and forwards it to the TTY. This xterm + websocket idea is inspired by [Wetty](https://github.com/krishnasrinivas/wetty).
|
||||
|
||||
## Alternatives
|
||||
|
||||
@ -179,6 +172,7 @@ GoTTY uses [hterm](https://groups.google.com/a/chromium.org/forum/#!forum/chromi
|
||||
|
||||
* [Secure Shell (Chrome App)](https://chrome.google.com/webstore/detail/secure-shell/pnhechapfaindjhompbnflcldabbghjo): If you are a chrome user and need a "real" SSH client on your web browser, perhaps the Secure Shell app is what you want
|
||||
* [Wetty](https://github.com/krishnasrinivas/wetty): Node based web terminal (SSH/login)
|
||||
* [ttyd](https://tsl0922.github.io/ttyd): C port of GoTTY with CJK and IME support
|
||||
|
||||
### Terminal Sharing
|
||||
|
||||
@ -189,3 +183,95 @@ GoTTY uses [hterm](https://groups.google.com/a/chromium.org/forum/#!forum/chromi
|
||||
# License
|
||||
|
||||
The MIT License
|
||||
|
||||
# Contributors
|
||||
|
||||
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
||||
<!-- prettier-ignore-start -->
|
||||
<!-- markdownlint-disable -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="https://yudai.arielworks.com/"><img src="https://avatars.githubusercontent.com/u/33192?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Iwasaki Yudai</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=yudai" title="Code">💻</a></td>
|
||||
<td align="center"><a href="http://linux2go.dk/"><img src="https://avatars.githubusercontent.com/u/160090?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Soren L. Hansen</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Asorenisanerd" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/uovobw"><img src="https://avatars.githubusercontent.com/u/1194751?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andrea Lusuardi</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=uovobw" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/moul"><img src="https://avatars.githubusercontent.com/u/94029?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Manfred Touron</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=moul" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/svanellewee"><img src="https://avatars.githubusercontent.com/u/1567439?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stephan</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=svanellewee" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://fr.linkedin.com/in/quentinperez"><img src="https://avatars.githubusercontent.com/u/3081204?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Quentin Perez</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=QuentinPerez" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/jizhilong"><img src="https://avatars.githubusercontent.com/u/816618?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jzl</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=jizhilong" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://majid.info/"><img src="https://avatars.githubusercontent.com/u/331198?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Fazal Majid</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=fazalmajid" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://narrationbox.com/"><img src="https://avatars.githubusercontent.com/u/7126128?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Immortalin</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=Immortalin" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/freakhill"><img src="https://avatars.githubusercontent.com/u/916582?v=4?s=100" width="100px;" alt=""/><br /><sub><b>freakhill</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=freakhill" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/0xflotus"><img src="https://avatars.githubusercontent.com/u/26602940?v=4?s=100" width="100px;" alt=""/><br /><sub><b>0xflotus</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=0xflotus" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://andy.blog/"><img src="https://avatars.githubusercontent.com/u/52292?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andy Skelton</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=skeltoac" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://twitter.com/artdevjs"><img src="https://avatars.githubusercontent.com/u/7567983?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Artem Medvedev</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=artdevjs" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/blakejennings"><img src="https://avatars.githubusercontent.com/u/1976331?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Blake Jennings</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=blakejennings" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/jensenbox"><img src="https://avatars.githubusercontent.com/u/189265?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christian Jensen</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=jensenbox" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://wilk.tech/"><img src="https://avatars.githubusercontent.com/u/9367803?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Christopher Wilkinson</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=TechWilk" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/RealCyGuy"><img src="https://avatars.githubusercontent.com/u/54488650?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Cyrus</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=RealCyGuy" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/dehorsley"><img src="https://avatars.githubusercontent.com/u/3401668?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Horsley</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=dehorsley" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://jasoncooke.dev/"><img src="https://avatars.githubusercontent.com/u/5185660?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jason Cooke</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=Jason-Cooke" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/DenKoren"><img src="https://avatars.githubusercontent.com/u/3419381?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Denis Korenevskiy</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=DenKoren" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://www.stucchi.ch/"><img src="https://avatars.githubusercontent.com/u/1331438?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Massimiliano Stucchi</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=stucchimax" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://www.linkedin.com/in/felixoid/"><img src="https://avatars.githubusercontent.com/u/3025537?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mikhail f. Shiryaev</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=Felixoid" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/guywithnose"><img src="https://avatars.githubusercontent.com/u/1059169?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Robert Bittle</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=guywithnose" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://deebas.com/"><img src="https://avatars.githubusercontent.com/u/283482?v=4?s=100" width="100px;" alt=""/><br /><sub><b>sebastian haas</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=sehaas" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/shoz"><img src="https://avatars.githubusercontent.com/u/225194?v=4?s=100" width="100px;" alt=""/><br /><sub><b>shoji</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=shoz" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/tsl0922"><img src="https://avatars.githubusercontent.com/u/1680515?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shuanglei Tao</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=tsl0922" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://gitter.im/"><img src="https://avatars.githubusercontent.com/u/8518239?v=4?s=100" width="100px;" alt=""/><br /><sub><b>The Gitter Badger</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=gitter-badger" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/xinsnake"><img src="https://avatars.githubusercontent.com/u/1287677?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jacob Zhou</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=xinsnake" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/zyfdegh"><img src="https://avatars.githubusercontent.com/u/7880217?v=4?s=100" width="100px;" alt=""/><br /><sub><b>zyfdegh</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=zyfdegh" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/fredster33"><img src="https://avatars.githubusercontent.com/u/64927044?v=4?s=100" width="100px;" alt=""/><br /><sub><b>fredster33</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=fredster33" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://mattn.kaoriya.net/"><img src="https://avatars.githubusercontent.com/u/10111?v=4?s=100" width="100px;" alt=""/><br /><sub><b>mattn</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=mattn" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://www.shingt.com/"><img src="https://avatars.githubusercontent.com/u/1391330?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shinichi Goto</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=shingt" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://twitter.com/_yogeshsingh"><img src="https://avatars.githubusercontent.com/u/8512357?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ygit</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=ygit" title="Code">💻</a></td>
|
||||
<td align="center"><a href="http://forum.cachem.fr/viewforum.php?f=21"><img src="https://avatars.githubusercontent.com/u/3392684?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stéphane</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Anephaste" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://rusnak.io/"><img src="https://avatars.githubusercontent.com/u/42201?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pavol Rusnak</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Aprusnak" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/devanlai"><img src="https://avatars.githubusercontent.com/u/1348448?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Devan Lai</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=devanlai" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/jkandasa"><img src="https://avatars.githubusercontent.com/u/1004403?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeeva Kandasamy</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=jkandasa" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://twitch.tv/iamhardliner"><img src="https://avatars.githubusercontent.com/u/2937272?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Steve Biedermann</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/commits?author=hardliner66" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/xgdgsc"><img src="https://avatars.githubusercontent.com/u/1189869?v=4?s=100" width="100px;" alt=""/><br /><sub><b>xgdgsc</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Axgdgsc" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/flechaig"><img src="https://avatars.githubusercontent.com/u/10887132?v=4?s=100" width="100px;" alt=""/><br /><sub><b>flechaig</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Aflechaig" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/Fan-SJ"><img src="https://avatars.githubusercontent.com/u/49977708?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Fan-SJ</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3AFan-SJ" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/dmartin"><img src="https://avatars.githubusercontent.com/u/1657652?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dustin Martin</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Admartin" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://ahmet.dev/"><img src="https://avatars.githubusercontent.com/u/159209?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ahmet Alp Balkan</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Aahmetb" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/CoconutMacaroon"><img src="https://avatars.githubusercontent.com/u/45187468?v=4?s=100" width="100px;" alt=""/><br /><sub><b>CoconutMacaroon</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3ACoconutMacaroon" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.dannyben.com/"><img src="https://avatars.githubusercontent.com/u/2405099?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Danny Ben Shitrit</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3ADannyBen" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/George-NG"><img src="https://avatars.githubusercontent.com/u/28577165?v=4?s=100" width="100px;" alt=""/><br /><sub><b>George-NG</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3AGeorge-NG" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/ghthor"><img src="https://avatars.githubusercontent.com/u/160298?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Will Owens</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Aghthor" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://jpillora.com/"><img src="https://avatars.githubusercontent.com/u/633843?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jaime Pillora</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Ajpillora" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/kaisawind"><img src="https://avatars.githubusercontent.com/u/4010613?v=4?s=100" width="100px;" alt=""/><br /><sub><b>kaisawind</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Akaisawind" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/linyinli"><img src="https://avatars.githubusercontent.com/u/42955482?v=4?s=100" width="100px;" alt=""/><br /><sub><b>linyinli</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Alinyinli" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/LucaMarconato"><img src="https://avatars.githubusercontent.com/u/2664412?v=4?s=100" width="100px;" alt=""/><br /><sub><b>LucaMarconato</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3ALucaMarconato" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://audiobox.fm/"><img src="https://avatars.githubusercontent.com/u/12844?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kain</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Amasterkain" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="http://duro.me/"><img src="https://avatars.githubusercontent.com/u/1498061?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andi Andreas</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3ANexuist" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/qigj"><img src="https://avatars.githubusercontent.com/u/56585735?v=4?s=100" width="100px;" alt=""/><br /><sub><b>qigj</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Aqigj" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/shuaiyy"><img src="https://avatars.githubusercontent.com/u/19821321?v=4?s=100" width="100px;" alt=""/><br /><sub><b>shuaiyy</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Ashuaiyy" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/v20z"><img src="https://avatars.githubusercontent.com/u/2884824?v=4?s=100" width="100px;" alt=""/><br /><sub><b>v20z</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3Av20z" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/Yann-Qiu"><img src="https://avatars.githubusercontent.com/u/56961747?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yanfeng Qiu</b></sub></a><br /><a href="https://github.com/sorenisanerd/gotty/issues?q=author%3AYann-Qiu" title="Bug reports">🐛</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- markdownlint-restore -->
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
||||
|
||||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
||||
|
6
README.md.sed
Normal file
@ -0,0 +1,6 @@
|
||||
/^## Options/,/^### Config File/ {
|
||||
/^\(`\|#\)/!d # Delete any line not beginning with ` or #
|
||||
/```sh/ { # Shove options.txt.tmp in after ```sh
|
||||
r options.txt.tmp
|
||||
}
|
||||
}
|
511
app/app.go
@ -1,511 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/big"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/braintree/manners"
|
||||
"github.com/elazarl/go-bindata-assetfs"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/kr/pty"
|
||||
"github.com/yudai/hcl"
|
||||
"github.com/yudai/umutex"
|
||||
)
|
||||
|
||||
type InitMessage struct {
|
||||
Arguments string `json:"Arguments,omitempty"`
|
||||
AuthToken string `json:"AuthToken,omitempty"`
|
||||
}
|
||||
|
||||
type App struct {
|
||||
command []string
|
||||
options *Options
|
||||
|
||||
upgrader *websocket.Upgrader
|
||||
server *manners.GracefulServer
|
||||
|
||||
titleTemplate *template.Template
|
||||
|
||||
onceMutex *umutex.UnblockingMutex
|
||||
timer *time.Timer
|
||||
|
||||
// clientContext writes concurrently
|
||||
// Use atomic operations.
|
||||
connections *int64
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
Address string `hcl:"address"`
|
||||
Port string `hcl:"port"`
|
||||
PermitWrite bool `hcl:"permit_write"`
|
||||
EnableBasicAuth bool `hcl:"enable_basic_auth"`
|
||||
Credential string `hcl:"credential"`
|
||||
EnableRandomUrl bool `hcl:"enable_random_url"`
|
||||
RandomUrlLength int `hcl:"random_url_length"`
|
||||
IndexFile string `hcl:"index_file"`
|
||||
EnableTLS bool `hcl:"enable_tls"`
|
||||
TLSCrtFile string `hcl:"tls_crt_file"`
|
||||
TLSKeyFile string `hcl:"tls_key_file"`
|
||||
EnableTLSClientAuth bool `hcl:"enable_tls_client_auth"`
|
||||
TLSCACrtFile string `hcl:"tls_ca_crt_file"`
|
||||
TitleFormat string `hcl:"title_format"`
|
||||
EnableReconnect bool `hcl:"enable_reconnect"`
|
||||
ReconnectTime int `hcl:"reconnect_time"`
|
||||
MaxConnection int `hcl:"max_connection"`
|
||||
Once bool `hcl:"once"`
|
||||
Timeout int `hcl:"timeout"`
|
||||
PermitArguments bool `hcl:"permit_arguments"`
|
||||
CloseSignal int `hcl:"close_signal"`
|
||||
Preferences HtermPrefernces `hcl:"preferences"`
|
||||
RawPreferences map[string]interface{} `hcl:"preferences"`
|
||||
Width int `hcl:"width"`
|
||||
Height int `hcl:"height"`
|
||||
}
|
||||
|
||||
var Version = "0.0.13"
|
||||
|
||||
var DefaultOptions = Options{
|
||||
Address: "",
|
||||
Port: "8080",
|
||||
PermitWrite: false,
|
||||
EnableBasicAuth: false,
|
||||
Credential: "",
|
||||
EnableRandomUrl: false,
|
||||
RandomUrlLength: 8,
|
||||
IndexFile: "",
|
||||
EnableTLS: false,
|
||||
TLSCrtFile: "~/.gotty.crt",
|
||||
TLSKeyFile: "~/.gotty.key",
|
||||
EnableTLSClientAuth: false,
|
||||
TLSCACrtFile: "~/.gotty.ca.crt",
|
||||
TitleFormat: "GoTTY - {{ .Command }} ({{ .Hostname }})",
|
||||
EnableReconnect: false,
|
||||
ReconnectTime: 10,
|
||||
MaxConnection: 0,
|
||||
Once: false,
|
||||
CloseSignal: 1, // syscall.SIGHUP
|
||||
Preferences: HtermPrefernces{},
|
||||
Width: 0,
|
||||
Height: 0,
|
||||
}
|
||||
|
||||
func New(command []string, options *Options) (*App, error) {
|
||||
titleTemplate, err := template.New("title").Parse(options.TitleFormat)
|
||||
if err != nil {
|
||||
return nil, errors.New("Title format string syntax error")
|
||||
}
|
||||
|
||||
connections := int64(0)
|
||||
|
||||
return &App{
|
||||
command: command,
|
||||
options: options,
|
||||
|
||||
upgrader: &websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
Subprotocols: []string{"gotty"},
|
||||
},
|
||||
|
||||
titleTemplate: titleTemplate,
|
||||
|
||||
onceMutex: umutex.New(),
|
||||
connections: &connections,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ApplyConfigFile(options *Options, filePath string) error {
|
||||
filePath = ExpandHomeDir(filePath)
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
fileString := []byte{}
|
||||
log.Printf("Loading config file at: %s", filePath)
|
||||
fileString, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := hcl.Decode(options, string(fileString)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CheckConfig(options *Options) error {
|
||||
if options.EnableTLSClientAuth && !options.EnableTLS {
|
||||
return errors.New("TLS client authentication is enabled, but TLS is not enabled")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (app *App) Run() error {
|
||||
if app.options.PermitWrite {
|
||||
log.Printf("Permitting clients to write input to the PTY.")
|
||||
}
|
||||
|
||||
if app.options.Once {
|
||||
log.Printf("Once option is provided, accepting only one client")
|
||||
}
|
||||
|
||||
path := ""
|
||||
if app.options.EnableRandomUrl {
|
||||
path += "/" + generateRandomString(app.options.RandomUrlLength)
|
||||
}
|
||||
|
||||
endpoint := net.JoinHostPort(app.options.Address, app.options.Port)
|
||||
|
||||
wsHandler := http.HandlerFunc(app.handleWS)
|
||||
customIndexHandler := http.HandlerFunc(app.handleCustomIndex)
|
||||
authTokenHandler := http.HandlerFunc(app.handleAuthToken)
|
||||
staticHandler := http.FileServer(
|
||||
&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "static"},
|
||||
)
|
||||
|
||||
var siteMux = http.NewServeMux()
|
||||
|
||||
if app.options.IndexFile != "" {
|
||||
log.Printf("Using index file at " + app.options.IndexFile)
|
||||
siteMux.Handle(path+"/", customIndexHandler)
|
||||
} else {
|
||||
siteMux.Handle(path+"/", http.StripPrefix(path+"/", staticHandler))
|
||||
}
|
||||
siteMux.Handle(path+"/auth_token.js", authTokenHandler)
|
||||
siteMux.Handle(path+"/js/", http.StripPrefix(path+"/", staticHandler))
|
||||
siteMux.Handle(path+"/favicon.png", http.StripPrefix(path+"/", staticHandler))
|
||||
|
||||
siteHandler := http.Handler(siteMux)
|
||||
|
||||
if app.options.EnableBasicAuth {
|
||||
log.Printf("Using Basic Authentication")
|
||||
siteHandler = wrapBasicAuth(siteHandler, app.options.Credential)
|
||||
}
|
||||
|
||||
siteHandler = wrapHeaders(siteHandler)
|
||||
|
||||
wsMux := http.NewServeMux()
|
||||
wsMux.Handle("/", siteHandler)
|
||||
wsMux.Handle(path+"/ws", wsHandler)
|
||||
siteHandler = (http.Handler(wsMux))
|
||||
|
||||
siteHandler = wrapLogger(siteHandler)
|
||||
|
||||
scheme := "http"
|
||||
if app.options.EnableTLS {
|
||||
scheme = "https"
|
||||
}
|
||||
log.Printf(
|
||||
"Server is starting with command: %s",
|
||||
strings.Join(app.command, " "),
|
||||
)
|
||||
if app.options.Address != "" {
|
||||
log.Printf(
|
||||
"URL: %s",
|
||||
(&url.URL{Scheme: scheme, Host: endpoint, Path: path + "/"}).String(),
|
||||
)
|
||||
} else {
|
||||
for _, address := range listAddresses() {
|
||||
log.Printf(
|
||||
"URL: %s",
|
||||
(&url.URL{
|
||||
Scheme: scheme,
|
||||
Host: net.JoinHostPort(address, app.options.Port),
|
||||
Path: path + "/",
|
||||
}).String(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
server, err := app.makeServer(endpoint, &siteHandler)
|
||||
if err != nil {
|
||||
return errors.New("Failed to build server: " + err.Error())
|
||||
}
|
||||
app.server = manners.NewWithServer(
|
||||
server,
|
||||
)
|
||||
|
||||
if app.options.Timeout > 0 {
|
||||
app.timer = time.NewTimer(time.Duration(app.options.Timeout) * time.Second)
|
||||
go func() {
|
||||
<-app.timer.C
|
||||
app.Exit()
|
||||
}()
|
||||
}
|
||||
|
||||
if app.options.EnableTLS {
|
||||
crtFile := ExpandHomeDir(app.options.TLSCrtFile)
|
||||
keyFile := ExpandHomeDir(app.options.TLSKeyFile)
|
||||
log.Printf("TLS crt file: " + crtFile)
|
||||
log.Printf("TLS key file: " + keyFile)
|
||||
|
||||
err = app.server.ListenAndServeTLS(crtFile, keyFile)
|
||||
} else {
|
||||
err = app.server.ListenAndServe()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("Exiting...")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (app *App) makeServer(addr string, handler *http.Handler) (*http.Server, error) {
|
||||
server := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: *handler,
|
||||
}
|
||||
|
||||
if app.options.EnableTLSClientAuth {
|
||||
caFile := ExpandHomeDir(app.options.TLSCACrtFile)
|
||||
log.Printf("CA file: " + caFile)
|
||||
caCert, err := ioutil.ReadFile(caFile)
|
||||
if err != nil {
|
||||
return nil, errors.New("Could not open CA crt file " + caFile)
|
||||
}
|
||||
caCertPool := x509.NewCertPool()
|
||||
if !caCertPool.AppendCertsFromPEM(caCert) {
|
||||
return nil, errors.New("Could not parse CA crt file data in " + caFile)
|
||||
}
|
||||
tlsConfig := &tls.Config{
|
||||
ClientCAs: caCertPool,
|
||||
ClientAuth: tls.RequireAndVerifyClientCert,
|
||||
}
|
||||
server.TLSConfig = tlsConfig
|
||||
}
|
||||
|
||||
return server, nil
|
||||
}
|
||||
|
||||
func (app *App) stopTimer() {
|
||||
if app.options.Timeout > 0 {
|
||||
app.timer.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
func (app *App) restartTimer() {
|
||||
if app.options.Timeout > 0 {
|
||||
app.timer.Reset(time.Duration(app.options.Timeout) * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func (app *App) handleWS(w http.ResponseWriter, r *http.Request) {
|
||||
app.stopTimer()
|
||||
|
||||
connections := atomic.AddInt64(app.connections, 1)
|
||||
if int64(app.options.MaxConnection) != 0 {
|
||||
if connections >= int64(app.options.MaxConnection) {
|
||||
log.Printf("Reached max connection: %d", app.options.MaxConnection)
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Printf("New client connected: %s", r.RemoteAddr)
|
||||
|
||||
if r.Method != "GET" {
|
||||
http.Error(w, "Method not allowed", 405)
|
||||
return
|
||||
}
|
||||
|
||||
conn, err := app.upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
log.Print("Failed to upgrade connection: " + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
_, stream, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
log.Print("Failed to authenticate websocket connection")
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
var init InitMessage
|
||||
|
||||
err = json.Unmarshal(stream, &init)
|
||||
if err != nil {
|
||||
log.Printf("Failed to parse init message %v", err)
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
if init.AuthToken != app.options.Credential {
|
||||
log.Print("Failed to authenticate websocket connection")
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
argv := app.command[1:]
|
||||
if app.options.PermitArguments {
|
||||
if init.Arguments == "" {
|
||||
init.Arguments = "?"
|
||||
}
|
||||
query, err := url.Parse(init.Arguments)
|
||||
if err != nil {
|
||||
log.Print("Failed to parse arguments")
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
params := query.Query()["arg"]
|
||||
if len(params) != 0 {
|
||||
argv = append(argv, params...)
|
||||
}
|
||||
}
|
||||
|
||||
app.server.StartRoutine()
|
||||
|
||||
if app.options.Once {
|
||||
if app.onceMutex.TryLock() { // no unlock required, it will die soon
|
||||
log.Printf("Last client accepted, closing the listener.")
|
||||
app.server.Close()
|
||||
} else {
|
||||
log.Printf("Server is already closing.")
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
cmd := exec.Command(app.command[0], argv...)
|
||||
ptyIo, err := pty.Start(cmd)
|
||||
if err != nil {
|
||||
log.Print("Failed to execute command")
|
||||
return
|
||||
}
|
||||
|
||||
if app.options.MaxConnection != 0 {
|
||||
log.Printf("Command is running for client %s with PID %d (args=%q), connections: %d/%d",
|
||||
r.RemoteAddr, cmd.Process.Pid, strings.Join(argv, " "), connections, app.options.MaxConnection)
|
||||
} else {
|
||||
log.Printf("Command is running for client %s with PID %d (args=%q), connections: %d",
|
||||
r.RemoteAddr, cmd.Process.Pid, strings.Join(argv, " "), connections)
|
||||
}
|
||||
|
||||
context := &clientContext{
|
||||
app: app,
|
||||
request: r,
|
||||
connection: conn,
|
||||
command: cmd,
|
||||
pty: ptyIo,
|
||||
writeMutex: &sync.Mutex{},
|
||||
}
|
||||
|
||||
context.goHandleClient()
|
||||
}
|
||||
|
||||
func (app *App) handleCustomIndex(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, ExpandHomeDir(app.options.IndexFile))
|
||||
}
|
||||
|
||||
func (app *App) handleAuthToken(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
w.Write([]byte("var gotty_auth_token = '" + app.options.Credential + "';"))
|
||||
}
|
||||
|
||||
func (app *App) Exit() (firstCall bool) {
|
||||
if app.server != nil {
|
||||
firstCall = app.server.Close()
|
||||
if firstCall {
|
||||
log.Printf("Received Exit command, waiting for all clients to close sessions...")
|
||||
}
|
||||
return firstCall
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func wrapLogger(handler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
rw := &responseWrapper{w, 200}
|
||||
handler.ServeHTTP(rw, r)
|
||||
log.Printf("%s %d %s %s", r.RemoteAddr, rw.status, r.Method, r.URL.Path)
|
||||
})
|
||||
}
|
||||
|
||||
func wrapHeaders(handler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Server", "GoTTY/"+Version)
|
||||
handler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func wrapBasicAuth(handler http.Handler, credential string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
token := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
|
||||
|
||||
if len(token) != 2 || strings.ToLower(token[0]) != "basic" {
|
||||
w.Header().Set("WWW-Authenticate", `Basic realm="GoTTY"`)
|
||||
http.Error(w, "Bad Request", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
payload, err := base64.StdEncoding.DecodeString(token[1])
|
||||
if err != nil {
|
||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if credential != string(payload) {
|
||||
w.Header().Set("WWW-Authenticate", `Basic realm="GoTTY"`)
|
||||
http.Error(w, "authorization failed", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Basic Authentication Succeeded: %s", r.RemoteAddr)
|
||||
handler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func generateRandomString(length int) string {
|
||||
const base = 36
|
||||
size := big.NewInt(base)
|
||||
n := make([]byte, length)
|
||||
for i, _ := range n {
|
||||
c, _ := rand.Int(rand.Reader, size)
|
||||
n[i] = strconv.FormatInt(c.Int64(), base)[0]
|
||||
}
|
||||
return string(n)
|
||||
}
|
||||
|
||||
func listAddresses() (addresses []string) {
|
||||
ifaces, _ := net.Interfaces()
|
||||
|
||||
addresses = make([]string, 0, len(ifaces))
|
||||
|
||||
for _, iface := range ifaces {
|
||||
ifAddrs, _ := iface.Addrs()
|
||||
for _, ifAddr := range ifAddrs {
|
||||
switch v := ifAddr.(type) {
|
||||
case *net.IPNet:
|
||||
addresses = append(addresses, v.IP.String())
|
||||
case *net.IPAddr:
|
||||
addresses = append(addresses, v.IP.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ExpandHomeDir(path string) string {
|
||||
if path[0:2] == "~/" {
|
||||
return os.Getenv("HOME") + path[1:]
|
||||
} else {
|
||||
return path
|
||||
}
|
||||
}
|
@ -1,241 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
type clientContext struct {
|
||||
app *App
|
||||
request *http.Request
|
||||
connection *websocket.Conn
|
||||
command *exec.Cmd
|
||||
pty *os.File
|
||||
writeMutex *sync.Mutex
|
||||
}
|
||||
|
||||
const (
|
||||
Input = '0'
|
||||
Ping = '1'
|
||||
ResizeTerminal = '2'
|
||||
)
|
||||
|
||||
const (
|
||||
Output = '0'
|
||||
Pong = '1'
|
||||
SetWindowTitle = '2'
|
||||
SetPreferences = '3'
|
||||
SetReconnect = '4'
|
||||
)
|
||||
|
||||
type argResizeTerminal struct {
|
||||
Columns float64
|
||||
Rows float64
|
||||
}
|
||||
|
||||
type ContextVars struct {
|
||||
Command string
|
||||
Pid int
|
||||
Hostname string
|
||||
RemoteAddr string
|
||||
}
|
||||
|
||||
func (context *clientContext) goHandleClient() {
|
||||
exit := make(chan bool, 2)
|
||||
|
||||
go func() {
|
||||
defer func() { exit <- true }()
|
||||
|
||||
context.processSend()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer func() { exit <- true }()
|
||||
|
||||
context.processReceive()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer context.app.server.FinishRoutine()
|
||||
defer func() {
|
||||
connections := atomic.AddInt64(context.app.connections, -1)
|
||||
|
||||
if context.app.options.MaxConnection != 0 {
|
||||
log.Printf("Connection closed: %s, connections: %d/%d",
|
||||
context.request.RemoteAddr, connections, context.app.options.MaxConnection)
|
||||
} else {
|
||||
log.Printf("Connection closed: %s, connections: %d",
|
||||
context.request.RemoteAddr, connections)
|
||||
}
|
||||
|
||||
if connections == 0 {
|
||||
context.app.restartTimer()
|
||||
}
|
||||
}()
|
||||
|
||||
<-exit
|
||||
context.pty.Close()
|
||||
|
||||
// Even if the PTY has been closed,
|
||||
// Read(0 in processSend() keeps blocking and the process doen't exit
|
||||
context.command.Process.Signal(syscall.Signal(context.app.options.CloseSignal))
|
||||
|
||||
context.command.Wait()
|
||||
context.connection.Close()
|
||||
}()
|
||||
}
|
||||
|
||||
func (context *clientContext) processSend() {
|
||||
if err := context.sendInitialize(); err != nil {
|
||||
log.Printf(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
buf := make([]byte, 1024)
|
||||
|
||||
for {
|
||||
size, err := context.pty.Read(buf)
|
||||
if err != nil {
|
||||
log.Printf("Command exited for: %s", context.request.RemoteAddr)
|
||||
return
|
||||
}
|
||||
safeMessage := base64.StdEncoding.EncodeToString([]byte(buf[:size]))
|
||||
if err = context.write(append([]byte{Output}, []byte(safeMessage)...)); err != nil {
|
||||
log.Printf(err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (context *clientContext) write(data []byte) error {
|
||||
context.writeMutex.Lock()
|
||||
defer context.writeMutex.Unlock()
|
||||
return context.connection.WriteMessage(websocket.TextMessage, data)
|
||||
}
|
||||
|
||||
func (context *clientContext) sendInitialize() error {
|
||||
hostname, _ := os.Hostname()
|
||||
titleVars := ContextVars{
|
||||
Command: strings.Join(context.app.command, " "),
|
||||
Pid: context.command.Process.Pid,
|
||||
Hostname: hostname,
|
||||
RemoteAddr: context.request.RemoteAddr,
|
||||
}
|
||||
|
||||
titleBuffer := new(bytes.Buffer)
|
||||
if err := context.app.titleTemplate.Execute(titleBuffer, titleVars); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := context.write(append([]byte{SetWindowTitle}, titleBuffer.Bytes()...)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prefStruct := structs.New(context.app.options.Preferences)
|
||||
prefMap := prefStruct.Map()
|
||||
htermPrefs := make(map[string]interface{})
|
||||
for key, value := range prefMap {
|
||||
rawKey := prefStruct.Field(key).Tag("hcl")
|
||||
if _, ok := context.app.options.RawPreferences[rawKey]; ok {
|
||||
htermPrefs[strings.Replace(rawKey, "_", "-", -1)] = value
|
||||
}
|
||||
}
|
||||
prefs, err := json.Marshal(htermPrefs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := context.write(append([]byte{SetPreferences}, prefs...)); err != nil {
|
||||
return err
|
||||
}
|
||||
if context.app.options.EnableReconnect {
|
||||
reconnect, _ := json.Marshal(context.app.options.ReconnectTime)
|
||||
if err := context.write(append([]byte{SetReconnect}, reconnect...)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (context *clientContext) processReceive() {
|
||||
for {
|
||||
_, data, err := context.connection.ReadMessage()
|
||||
if err != nil {
|
||||
log.Print(err.Error())
|
||||
return
|
||||
}
|
||||
if len(data) == 0 {
|
||||
log.Print("An error has occured")
|
||||
return
|
||||
}
|
||||
|
||||
switch data[0] {
|
||||
case Input:
|
||||
if !context.app.options.PermitWrite {
|
||||
break
|
||||
}
|
||||
|
||||
_, err := context.pty.Write(data[1:])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
case Ping:
|
||||
if err := context.write([]byte{Pong}); err != nil {
|
||||
log.Print(err.Error())
|
||||
return
|
||||
}
|
||||
case ResizeTerminal:
|
||||
var args argResizeTerminal
|
||||
err = json.Unmarshal(data[1:], &args)
|
||||
if err != nil {
|
||||
log.Print("Malformed remote command")
|
||||
return
|
||||
}
|
||||
|
||||
rows := uint16(context.app.options.Height)
|
||||
if rows == 0 {
|
||||
rows = uint16(args.Rows)
|
||||
}
|
||||
|
||||
columns := uint16(context.app.options.Width)
|
||||
if columns == 0 {
|
||||
columns = uint16(args.Columns)
|
||||
}
|
||||
|
||||
window := struct {
|
||||
row uint16
|
||||
col uint16
|
||||
x uint16
|
||||
y uint16
|
||||
}{
|
||||
rows,
|
||||
columns,
|
||||
0,
|
||||
0,
|
||||
}
|
||||
syscall.Syscall(
|
||||
syscall.SYS_IOCTL,
|
||||
context.pty.Fd(),
|
||||
syscall.TIOCSWINSZ,
|
||||
uintptr(unsafe.Pointer(&window)),
|
||||
)
|
||||
|
||||
default:
|
||||
log.Print("Unknown message type")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package app
|
||||
|
||||
type HtermPrefernces struct {
|
||||
AltGrMode *string `hcl:"alt_gr_mode"`
|
||||
AltBackspaceIsMetaBackspace bool `hcl:"alt_backspace_is_meta_backspace"`
|
||||
AltIsMeta bool `hcl:"alt_is_meta"`
|
||||
AltSendsWhat string `hcl:"alt_sends_what"`
|
||||
AudibleBellSound string `hcl:"audible_bell_sound"`
|
||||
DesktopNotificationBell bool `hcl:"desktop_notification_bell"`
|
||||
BackgroundColor string `hcl:"background_color"`
|
||||
BackgroundImage string `hcl:"background_image"`
|
||||
BackgroundSize string `hcl:"background_size"`
|
||||
BackgroundPosition string `hcl:"background_position"`
|
||||
BackspaceSendsBackspace bool `hcl:"backspace_sends_backspace"`
|
||||
CharacterMapOverrides map[string]map[string]string `hcl:"character_map_overrides"`
|
||||
CloseOnExit bool `hcl:"close_on_exit"`
|
||||
CursorBlink bool `hcl:"cursor_blink"`
|
||||
CursorBlinkCycle [2]int `hcl:"cursor_blink_cycle"`
|
||||
CursorColor string `hcl:"cursor_color"`
|
||||
ColorPaletteOverrides []*string `hcl:"color_palette_overrides"`
|
||||
CopyOnSelect bool `hcl:"copy_on_select"`
|
||||
UseDefaultWindowCopy bool `hcl:"use_default_window_copy"`
|
||||
ClearSelectionAfterCopy bool `hcl:"clear_selection_after_copy"`
|
||||
CtrlPlusMinusZeroZoom bool `hcl:"ctrl_plus_minus_zero_zoom"`
|
||||
CtrlCCopy bool `hcl:"ctrl_c_copy"`
|
||||
CtrlVPaste bool `hcl:"ctrl_v_paste"`
|
||||
EastAsianAmbiguousAsTwoColumn bool `hcl:"east_asian_ambiguous_as_two_column"`
|
||||
Enable8BitControl *bool `hcl:"enable_8_bit_control"`
|
||||
EnableBold *bool `hcl:"enable_bold"`
|
||||
EnableBoldAsBright bool `hcl:"enable_bold_as_bright"`
|
||||
EnableClipboardNotice bool `hcl:"enable_clipboard_notice"`
|
||||
EnableClipboardWrite bool `hcl:"enable_clipboard_write"`
|
||||
EnableDec12 bool `hcl:"enable_dec12"`
|
||||
Environment map[string]string `hcl:"environment"`
|
||||
FontFamily string `hcl:"font_family"`
|
||||
FontSize int `hcl:"font_size"`
|
||||
FontSmoothing string `hcl:"font_smoothing"`
|
||||
ForegroundColor string `hcl:"foreground_color"`
|
||||
HomeKeysScroll bool `hcl:"home_keys_scroll"`
|
||||
Keybindings map[string]string `hcl:"keybindings"`
|
||||
MaxStringSequence int `hcl:"max_string_sequence"`
|
||||
MediaKeysAreFkeys bool `hcl:"media_keys_are_fkeys"`
|
||||
MetaSendsEscape bool `hcl:"meta_sends_escape"`
|
||||
MousePasteButton *int `hcl:"mouse_paste_button"`
|
||||
PageKeysScroll bool `hcl:"page_keys_scroll"`
|
||||
PassAltNumber *bool `hcl:"pass_alt_number"`
|
||||
PassCtrlNumber *bool `hcl:"pass_ctrl_number"`
|
||||
PassMetaNumber *bool `hcl:"pass_meta_number"`
|
||||
PassMetaV bool `hcl:"pass_meta_v"`
|
||||
ReceiveEncoding string `hcl:"receive_encoding"`
|
||||
ScrollOnKeystroke bool `hcl:"scroll_on_keystroke"`
|
||||
ScrollOnOutput bool `hcl:"scroll_on_output"`
|
||||
ScrollbarVisible bool `hcl:"scrollbar_visible"`
|
||||
ScrollWheelMoveMultiplier int `hcl:"scroll_wheel_move_multiplier"`
|
||||
SendEncoding string `hcl:"send_encoding"`
|
||||
ShiftInsertPaste bool `hcl:"shift_insert_paste"`
|
||||
UserCss string `hcl:"user_css"`
|
||||
}
|
308
app/resource.go
1
backend/doc.go
Normal file
@ -0,0 +1 @@
|
||||
package backend
|
3
backend/localcommand/doc.go
Normal file
@ -0,0 +1,3 @@
|
||||
// Package localcommand provides an implementation of webtty.Slave
|
||||
// that launches a local command with a PTY.
|
||||
package localcommand
|
48
backend/localcommand/factory.go
Normal file
@ -0,0 +1,48 @@
|
||||
package localcommand
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/sorenisanerd/gotty/server"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
CloseSignal int `hcl:"close_signal" flagName:"close-signal" flagSName:"" flagDescribe:"Signal sent to the command process when gotty close it (default: SIGHUP)" default:"1"`
|
||||
CloseTimeout int `hcl:"close_timeout" flagName:"close-timeout" flagSName:"" flagDescribe:"Time in seconds to force kill process after client is disconnected (default: -1)" default:"-1"`
|
||||
}
|
||||
|
||||
type Factory struct {
|
||||
command string
|
||||
argv []string
|
||||
options *Options
|
||||
opts []Option
|
||||
}
|
||||
|
||||
func NewFactory(command string, argv []string, options *Options) (*Factory, error) {
|
||||
opts := []Option{WithCloseSignal(syscall.Signal(options.CloseSignal))}
|
||||
if options.CloseTimeout >= 0 {
|
||||
opts = append(opts, WithCloseTimeout(time.Duration(options.CloseTimeout)*time.Second))
|
||||
}
|
||||
|
||||
return &Factory{
|
||||
command: command,
|
||||
argv: argv,
|
||||
options: options,
|
||||
opts: opts,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (factory *Factory) Name() string {
|
||||
return "local command"
|
||||
}
|
||||
|
||||
func (factory *Factory) New(params map[string][]string, headers map[string][]string) (server.Slave, error) {
|
||||
argv := make([]string, len(factory.argv))
|
||||
copy(argv, factory.argv)
|
||||
if params["arg"] != nil && len(params["arg"]) > 0 {
|
||||
argv = append(argv, params["arg"]...)
|
||||
}
|
||||
|
||||
return New(factory.command, argv, headers, factory.opts...)
|
||||
}
|
135
backend/localcommand/local_command.go
Normal file
@ -0,0 +1,135 @@
|
||||
package localcommand
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/creack/pty"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultCloseSignal = syscall.SIGINT
|
||||
DefaultCloseTimeout = 10 * time.Second
|
||||
)
|
||||
|
||||
type LocalCommand struct {
|
||||
command string
|
||||
argv []string
|
||||
|
||||
closeSignal syscall.Signal
|
||||
closeTimeout time.Duration
|
||||
|
||||
cmd *exec.Cmd
|
||||
pty *os.File
|
||||
ptyClosed chan struct{}
|
||||
}
|
||||
|
||||
func New(command string, argv []string, headers map[string][]string, options ...Option) (*LocalCommand, error) {
|
||||
cmd := exec.Command(command, argv...)
|
||||
|
||||
cmd.Env = append(os.Environ(), "TERM=xterm-256color")
|
||||
|
||||
// Combine headers into key=value pairs to set as env vars
|
||||
// Prefix the headers with "http_" so we don't overwrite any other env vars
|
||||
// which potentially has the same name and to bring these closer to what
|
||||
// a (F)CGI server would proxy to a backend service
|
||||
// Replace hyphen with underscore and make them all upper case
|
||||
for key, values := range headers {
|
||||
h := "HTTP_" + strings.Replace(strings.ToUpper(key), "-", "_", -1) + "=" + strings.Join(values, ",")
|
||||
// log.Printf("Adding header: %s", h)
|
||||
cmd.Env = append(cmd.Env, h)
|
||||
}
|
||||
|
||||
pty, err := pty.Start(cmd)
|
||||
if err != nil {
|
||||
// todo close cmd?
|
||||
return nil, errors.Wrapf(err, "failed to start command `%s`", command)
|
||||
}
|
||||
ptyClosed := make(chan struct{})
|
||||
|
||||
lcmd := &LocalCommand{
|
||||
command: command,
|
||||
argv: argv,
|
||||
|
||||
closeSignal: DefaultCloseSignal,
|
||||
closeTimeout: DefaultCloseTimeout,
|
||||
|
||||
cmd: cmd,
|
||||
pty: pty,
|
||||
ptyClosed: ptyClosed,
|
||||
}
|
||||
|
||||
for _, option := range options {
|
||||
option(lcmd)
|
||||
}
|
||||
|
||||
// When the process is closed by the user,
|
||||
// close pty so that Read() on the pty breaks with an EOF.
|
||||
go func() {
|
||||
defer func() {
|
||||
lcmd.pty.Close()
|
||||
close(lcmd.ptyClosed)
|
||||
}()
|
||||
|
||||
lcmd.cmd.Wait()
|
||||
}()
|
||||
|
||||
return lcmd, nil
|
||||
}
|
||||
|
||||
func (lcmd *LocalCommand) Read(p []byte) (n int, err error) {
|
||||
return lcmd.pty.Read(p)
|
||||
}
|
||||
|
||||
func (lcmd *LocalCommand) Write(p []byte) (n int, err error) {
|
||||
return lcmd.pty.Write(p)
|
||||
}
|
||||
|
||||
func (lcmd *LocalCommand) Close() error {
|
||||
if lcmd.cmd != nil && lcmd.cmd.Process != nil {
|
||||
lcmd.cmd.Process.Signal(lcmd.closeSignal)
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case <-lcmd.ptyClosed:
|
||||
return nil
|
||||
case <-lcmd.closeTimeoutC():
|
||||
lcmd.cmd.Process.Signal(syscall.SIGKILL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (lcmd *LocalCommand) WindowTitleVariables() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"command": lcmd.command,
|
||||
"argv": lcmd.argv,
|
||||
"pid": lcmd.cmd.Process.Pid,
|
||||
}
|
||||
}
|
||||
|
||||
func (lcmd *LocalCommand) ResizeTerminal(width int, height int) error {
|
||||
window := pty.Winsize{
|
||||
Rows: uint16(height),
|
||||
Cols: uint16(width),
|
||||
X: 0,
|
||||
Y: 0,
|
||||
}
|
||||
err := pty.Setsize(lcmd.pty, &window)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (lcmd *LocalCommand) closeTimeoutC() <-chan time.Time {
|
||||
if lcmd.closeTimeout >= 0 {
|
||||
return time.After(lcmd.closeTimeout)
|
||||
}
|
||||
|
||||
return make(chan time.Time)
|
||||
}
|
88
backend/localcommand/local_command_test.go
Normal file
@ -0,0 +1,88 @@
|
||||
package localcommand
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestNewFactory(t *testing.T) {
|
||||
factory, err := NewFactory("/bin/false", []string{}, &Options{CloseSignal: 123, CloseTimeout: 321})
|
||||
if err != nil {
|
||||
t.Errorf("NewFactory() returned error")
|
||||
return
|
||||
}
|
||||
if factory.command != "/bin/false" {
|
||||
t.Errorf("factory.command = %v, expected %v", factory.command, "/bin/false")
|
||||
}
|
||||
if !reflect.DeepEqual(factory.argv, []string{}) {
|
||||
t.Errorf("factory.argv = %v, expected %v", factory.argv, []string{})
|
||||
}
|
||||
if !reflect.DeepEqual(factory.options, &Options{CloseSignal: 123, CloseTimeout: 321}) {
|
||||
t.Errorf("factory.options = %v, expected %v", factory.options, &Options{})
|
||||
}
|
||||
|
||||
slave, _ := factory.New(nil, nil)
|
||||
lcmd := slave.(*LocalCommand)
|
||||
if lcmd.closeSignal != 123 {
|
||||
t.Errorf("lcmd.closeSignal = %v, expected %v", lcmd.closeSignal, 123)
|
||||
}
|
||||
if lcmd.closeTimeout != time.Second*321 {
|
||||
t.Errorf("lcmd.closeTimeout = %v, expected %v", lcmd.closeTimeout, time.Second*321)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFactoryNew(t *testing.T) {
|
||||
factory, err := NewFactory("/bin/cat", []string{}, &Options{})
|
||||
if err != nil {
|
||||
t.Errorf("NewFactory() returned error")
|
||||
return
|
||||
}
|
||||
|
||||
slave, err := factory.New(nil, nil)
|
||||
if err != nil {
|
||||
t.Errorf("factory.New() returned error")
|
||||
return
|
||||
}
|
||||
|
||||
writeBuf := []byte("foobar\n")
|
||||
n, err := slave.Write(writeBuf)
|
||||
if err != nil {
|
||||
t.Errorf("write() failed: %v", err)
|
||||
return
|
||||
}
|
||||
if n != 7 {
|
||||
t.Errorf("Unexpected write length. n = %d, expected n = %d", n, 7)
|
||||
return
|
||||
}
|
||||
|
||||
// Local echo is on, so we get the output twice:
|
||||
// Once because we're "typing" it, and once more
|
||||
// repeated back to us by `cat`. Also, \r\n
|
||||
// because we're a terminal.
|
||||
expectedBuf := []byte("foobar\r\nfoobar\r\n")
|
||||
readBuf := make([]byte, 1024)
|
||||
var totalRead int
|
||||
for totalRead < 16 {
|
||||
n, err = slave.Read(readBuf[totalRead:])
|
||||
if err != nil {
|
||||
t.Errorf("read() failed: %v", err)
|
||||
return
|
||||
}
|
||||
totalRead += n
|
||||
}
|
||||
if totalRead != 16 {
|
||||
t.Errorf("Unexpected read length. totalRead = %d, expected totalRead = %d", totalRead, 16)
|
||||
return
|
||||
}
|
||||
if !bytes.Equal(readBuf[:totalRead], expectedBuf) {
|
||||
t.Errorf("unexpected output from slave: got %v, expected %v", readBuf[:totalRead], expectedBuf)
|
||||
}
|
||||
err = slave.Close()
|
||||
if err != nil {
|
||||
t.Errorf("close() failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
20
backend/localcommand/options.go
Normal file
@ -0,0 +1,20 @@
|
||||
package localcommand
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Option func(*LocalCommand)
|
||||
|
||||
func WithCloseSignal(signal syscall.Signal) Option {
|
||||
return func(lcmd *LocalCommand) {
|
||||
lcmd.closeSignal = signal
|
||||
}
|
||||
}
|
||||
|
||||
func WithCloseTimeout(timeout time.Duration) Option {
|
||||
return func(lcmd *LocalCommand) {
|
||||
lcmd.closeTimeout = timeout
|
||||
}
|
||||
}
|
8
bindata/bindata.go
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build !dev
|
||||
|
||||
package bindata
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed static/*
|
||||
var Fs embed.FS
|
28
bindata/bindata_dev.go
Normal file
@ -0,0 +1,28 @@
|
||||
//go:build dev
|
||||
|
||||
package bindata
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
)
|
||||
|
||||
type GottyFS struct {
|
||||
fs.FS
|
||||
}
|
||||
|
||||
var Fs GottyFS
|
||||
|
||||
func (gfs *GottyFS) ReadFile(name string) ([]byte, error) {
|
||||
fp, err := gfs.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return io.ReadAll(fp)
|
||||
}
|
||||
|
||||
func init() {
|
||||
Fs = GottyFS{os.DirFS("bindata")}
|
||||
}
|
13
bindata/static/css/index.css
Normal file
@ -0,0 +1,13 @@
|
||||
html, body, #terminal {
|
||||
background: black;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 0%;
|
||||
margin: 0%;
|
||||
}
|
||||
|
||||
.progress .progress-bar {
|
||||
transition: unset;
|
||||
transition-duration: 0.1s;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
209
bindata/static/css/xterm.css
Normal file
@ -0,0 +1,209 @@
|
||||
/**
|
||||
* Copyright (c) 2014 The xterm.js authors. All rights reserved.
|
||||
* Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
|
||||
* https://github.com/chjj/term.js
|
||||
* @license MIT
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* Originally forked from (with the author's permission):
|
||||
* Fabrice Bellard's javascript vt100 for jslinux:
|
||||
* http://bellard.org/jslinux/
|
||||
* Copyright (c) 2011 Fabrice Bellard
|
||||
* The original design remains. The terminal itself
|
||||
* has been extended to include xterm CSI codes, among
|
||||
* other features.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default styles for xterm.js
|
||||
*/
|
||||
|
||||
.xterm {
|
||||
cursor: text;
|
||||
position: relative;
|
||||
user-select: none;
|
||||
-ms-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
.xterm.focus,
|
||||
.xterm:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.xterm .xterm-helpers {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
/**
|
||||
* The z-index of the helpers must be higher than the canvases in order for
|
||||
* IMEs to appear on top.
|
||||
*/
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.xterm .xterm-helper-textarea {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
/* Move textarea out of the screen to the far left, so that the cursor is not visible */
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
left: -9999em;
|
||||
top: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
z-index: -5;
|
||||
/** Prevent wrapping so the IME appears against the textarea at the correct position */
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.xterm .composition-view {
|
||||
/* TODO: Composition position got messed up somewhere */
|
||||
background: #000;
|
||||
color: #FFF;
|
||||
display: none;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.xterm .composition-view.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.xterm .xterm-viewport {
|
||||
/* On OS X this is required in order for the scroll bar to appear fully opaque */
|
||||
background-color: #000;
|
||||
overflow-y: scroll;
|
||||
cursor: default;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.xterm .xterm-screen {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.xterm .xterm-screen canvas {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.xterm .xterm-scroll-area {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.xterm-char-measure-element {
|
||||
display: inline-block;
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -9999em;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.xterm.enable-mouse-events {
|
||||
/* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.xterm.xterm-cursor-pointer,
|
||||
.xterm .xterm-cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.xterm.column-select.focus {
|
||||
/* Column selection mode */
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.xterm .xterm-accessibility,
|
||||
.xterm .xterm-message {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
color: transparent;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.xterm .live-region {
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.xterm-dim {
|
||||
/* Dim should not apply to background, so the opacity of the foreground color is applied
|
||||
* explicitly in the generated class and reset to 1 here */
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
.xterm-underline-1 { text-decoration: underline; }
|
||||
.xterm-underline-2 { text-decoration: double underline; }
|
||||
.xterm-underline-3 { text-decoration: wavy underline; }
|
||||
.xterm-underline-4 { text-decoration: dotted underline; }
|
||||
.xterm-underline-5 { text-decoration: dashed underline; }
|
||||
|
||||
.xterm-overline {
|
||||
text-decoration: overline;
|
||||
}
|
||||
|
||||
.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
|
||||
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
|
||||
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
|
||||
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
|
||||
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }
|
||||
|
||||
.xterm-strikethrough {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.xterm-screen .xterm-decoration-container .xterm-decoration {
|
||||
z-index: 6;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
|
||||
z-index: 7;
|
||||
}
|
||||
|
||||
.xterm-decoration-overview-ruler {
|
||||
z-index: 8;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.xterm-decoration-top {
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
}
|
19
bindata/static/css/xterm_customize.css
Normal file
@ -0,0 +1,19 @@
|
||||
.terminal {
|
||||
font-family: "DejaVu Sans Mono", "Everson Mono", FreeMono, Menlo, Terminal, monospace, "Apple Symbols";
|
||||
}
|
||||
|
||||
.xterm-overlay {
|
||||
font-family: "DejaVu Sans Mono", "Everson Mono", FreeMono, Menlo, Terminal, monospace, "Apple Symbols";
|
||||
border-radius: 15px;
|
||||
font-size: xx-large;
|
||||
color: black;
|
||||
background: white;
|
||||
opacity: 0.75;
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
user-select: none;
|
||||
transition: opacity 180ms ease-in;
|
||||
}
|
BIN
bindata/static/favicon.ico
Normal file
After Width: | Height: | Size: 4.2 KiB |
66
bindata/static/icon.svg
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 708.4149 708.41411"
|
||||
height="708.41412"
|
||||
width="708.41492"
|
||||
xml:space="preserve"
|
||||
id="svg2"
|
||||
version="1.1"><metadata
|
||||
id="metadata8"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs6"><clipPath
|
||||
id="clipPath18"
|
||||
clipPathUnits="userSpaceOnUse"><path
|
||||
id="path16"
|
||||
d="M 0,2000 H 2000 V 0 H 0 Z" /></clipPath></defs><g
|
||||
transform="matrix(1.3333333,0,0,-1.3333333,-979.12558,1687.5405)"
|
||||
id="g10"><g
|
||||
id="g12"><g
|
||||
clip-path="url(#clipPath18)"
|
||||
id="g14"><g
|
||||
transform="translate(772.1414,1265.6554)"
|
||||
id="g20"><path
|
||||
id="path22"
|
||||
style="fill:#de3c28;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 c -20.875,0 -37.797,-16.922 -37.797,-37.797 v -126.348 -25.917 -212.342 L 345.882,0 Z" /></g><g
|
||||
transform="translate(956.8504,734.3448)"
|
||||
id="g24"><path
|
||||
id="path26"
|
||||
style="fill:#af1419;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 h 260.209 c 26.839,0 48.596,21.757 48.596,48.596 v 275.281 z" /></g><g
|
||||
transform="translate(1265.6552,1075.5929)"
|
||||
id="g28"><path
|
||||
id="path30"
|
||||
style="fill:#db0918;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 v 25.918 126.348 c 0,20.875 -16.922,37.796 -37.796,37.796 h -109.836 l -383.679,-402.404 v -80.31 c 0,-26.839 21.757,-48.596 48.596,-48.596 h 173.91 L 0,-17.371 Z" /></g><g
|
||||
transform="translate(1169.2147,909.6954)"
|
||||
id="g32"><path
|
||||
id="path34"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 h -138.227 c -9.129,0 -16.528,7.4 -16.528,16.529 0,9.128 7.399,16.529 16.528,16.529 H 0 c 9.129,0 16.528,-7.401 16.528,-16.529 C 16.528,7.4 9.129,0 0,0" /></g><g
|
||||
transform="translate(898.8318,1033.5314)"
|
||||
id="g36"><path
|
||||
id="path38"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 c 2.86,-0.72 5.65,-1.45 8.37,-2.2 -0.63,-8.56 -7.76,-15.3 -16.479,-15.3 -9.13,0 -16.531,7.4 -16.531,16.53 v 8.54 c 1.861,-0.83 3.72,-1.549 5.601,-2.15 C -15.199,4.18 -8.85,2.37 0,0" /></g><g
|
||||
transform="translate(907.2527,1150.7814)"
|
||||
id="g40"><path
|
||||
id="path42"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 v -65.81 c -4.45,1.59 -9.98,2.38 -16.601,2.38 -6.21,0 -11.7,-0.88 -16.46,-2.64 V 0 c 0,9.13 7.401,16.53 16.531,16.53 C -7.4,16.53 0,9.13 0,0" /></g><g
|
||||
transform="translate(874.1922,868.8272)"
|
||||
id="g44"><path
|
||||
id="path46"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 v 65.811 c 4.45,-1.59 9.98,-2.38 16.601,-2.38 6.21,0 11.699,0.88 16.46,2.639 V 0 C 33.061,-9.13 25.66,-16.529 16.53,-16.529 7.4,-16.529 0,-9.13 0,0" /></g><g
|
||||
transform="translate(966.6326,994.1915)"
|
||||
id="g48"><path
|
||||
id="path50"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 c -3.53,7.28 -8.45,13.3 -14.75,18.06 -6.301,4.76 -13.95,8.8 -22.94,12.14 -6.661,2.47 -13.911,4.78 -21.741,6.94 -2.719,0.75 -5.509,1.48 -8.37,2.2 -8.849,2.37 -15.199,4.18 -19.039,5.42 -1.881,0.6 -3.74,1.32 -5.6,2.15 -1.951,0.87 -3.88,1.87 -5.8,2.99 -3.76,2.19 -6.71,4.81 -8.861,7.85 -2.139,3.05 -3.219,6.67 -3.219,10.86 0,6.75 3.16,12.54 9.46,17.34 2.49,1.9 5.299,3.43 8.42,4.57 4.759,1.76 10.25,2.64 16.46,2.64 6.62,0 12.15,-0.79 16.6,-2.38 3.01,-1.05 5.52,-2.48 7.54,-4.26 5.01,-4.42 9.3,-10.59 12.88,-18.49 2.77,-5.52 5.34,-9.49 7.71,-11.92 2.37,-2.43 5.84,-3.64 10.399,-3.64 5.011,0 9.191,2.02 12.54,6.07 3.351,4.04 5.031,8.59 5.031,13.63 0,5.52 -1.34,11.19 -4.021,17 -2.689,5.8 -6.939,11.35 -12.75,16.63 -5.809,5.28 -13.119,9.52 -21.929,12.71 -5.23,1.89 -11.031,3.22 -17.4,3.99 -4.37,0.53 -9.011,0.79 -13.921,0.79 -6.779,0 -13.159,-0.48 -19.139,-1.45 -7.361,-1.19 -14.121,-3.11 -20.29,-5.76 -11.18,-4.81 -19.72,-11.69 -25.621,-20.63 -5.899,-8.95 -8.849,-19.18 -8.849,-30.7 0,-12.09 2.79,-22.2 8.38,-30.34 5.59,-8.14 13.15,-14.56 22.67,-19.28 9.52,-4.71 21.349,-8.83 35.48,-12.35 10.55,-2.57 18.98,-4.99 25.279,-7.28 6.301,-2.28 11.441,-5.59 15.42,-9.92 3.981,-4.33 5.971,-9.97 5.971,-16.92 0,-8.76 -3.69,-16.06 -11.061,-21.92 -7.379,-5.85 -16.969,-8.78 -28.769,-8.78 -8.59,0 -15.521,1.45 -20.79,4.36 -5.28,2.9 -9.37,6.59 -12.28,11.06 -2.901,4.47 -5.611,10.04 -8.111,16.71 -2.059,5.61 -4.54,9.85 -7.449,12.7 -2.9,2.86 -6.46,4.29 -10.66,4.29 -5.181,0 -9.45,-1.84 -12.811,-5.5 -3.349,-3.66 -5.029,-8.07 -5.029,-13.21 0,-8.85 2.8,-17.96 8.39,-27.34 5.58,-9.38 12.849,-16.87 21.79,-22.49 12.61,-7.8 28.61,-11.7 48.019,-11.7 16.181,0 30.181,2.85 41.981,8.56 11.809,5.71 20.769,13.61 26.9,23.7 6.119,10.09 9.18,21.47 9.18,34.129 C 5.3,-16.21 3.54,-7.28 0,0" /></g></g></g></g></svg>
|
After Width: | Height: | Size: 5.3 KiB |
BIN
bindata/static/icon_192.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
22
bindata/static/index.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>{{ .title }}</title>
|
||||
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
|
||||
<link rel="icon" href="favicon.ico">
|
||||
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="./css/index.css" />
|
||||
<link rel="stylesheet" href="./css/xterm.css" />
|
||||
<link rel="stylesheet" href="./css/xterm_customize.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="terminal"></div>
|
||||
<script src="./auth_token.js"></script>
|
||||
<script src="./config.js"></script>
|
||||
<script src="./js/gotty.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
3
bindata/static/js/gotty.js
Normal file
7
bindata/static/js/gotty.js.LICENSE.txt
Normal file
@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* Bootstrap v5.3.2 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
|
1
bindata/static/js/gotty.js.map
Normal file
649
bindata/static/js/gotty.licenses.txt
Normal file
@ -0,0 +1,649 @@
|
||||
@popperjs/core
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 Federico Zivolo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
bootstrap
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011-2023 The Bootstrap Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
crc-32
|
||||
Apache-2.0
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright (C) 2014-present SheetJS LLC
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
css-loader
|
||||
MIT
|
||||
Copyright JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
jsx-runtime
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
preact
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-present Jason Miller
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
style-loader
|
||||
MIT
|
||||
Copyright JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
xterm
|
||||
MIT
|
||||
Copyright (c) 2017-2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
|
||||
Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com)
|
||||
Copyright (c) 2012-2013, Christopher Jeffrey (https://github.com/chjj/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
xterm-addon-fit
|
||||
MIT
|
||||
Copyright (c) 2019, The xterm.js authors (https://github.com/xtermjs/xterm.js)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
xterm-addon-web-links
|
||||
MIT
|
||||
Copyright (c) 2017, The xterm.js authors (https://github.com/xtermjs/xterm.js)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
xterm-addon-webgl
|
||||
MIT
|
||||
Copyright (c) 2018, The xterm.js authors (https://github.com/xtermjs/xterm.js)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
zmodem.js
|
||||
Apache-2.0
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
15
bindata/static/manifest.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"short_name": "{{ .title }}",
|
||||
"name": "{{ .title }}",
|
||||
"start_url": "./",
|
||||
"icons": [
|
||||
{
|
||||
"src": "./icon_192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
}
|
||||
],
|
||||
"display": "minimal-ui",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#000000"
|
||||
}
|
3623
favicon.ai
Normal file
BIN
favicon.psd
101
flags.go
@ -1,101 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/fatih/structs"
|
||||
|
||||
"github.com/yudai/gotty/app"
|
||||
)
|
||||
|
||||
type flag struct {
|
||||
name string
|
||||
shortName string
|
||||
description string
|
||||
}
|
||||
|
||||
func generateFlags(flags []flag, hint map[string]string) ([]cli.Flag, error) {
|
||||
o := structs.New(app.DefaultOptions)
|
||||
|
||||
results := make([]cli.Flag, len(flags))
|
||||
|
||||
for i, flag := range flags {
|
||||
fieldName := fieldName(flag.name, hint)
|
||||
|
||||
field, ok := o.FieldOk(fieldName)
|
||||
if !ok {
|
||||
return nil, errors.New("No such field: " + fieldName)
|
||||
}
|
||||
|
||||
flagName := flag.name
|
||||
if flag.shortName != "" {
|
||||
flagName += ", " + flag.shortName
|
||||
}
|
||||
envName := "GOTTY_" + strings.ToUpper(strings.Join(strings.Split(flag.name, "-"), "_"))
|
||||
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
results[i] = cli.StringFlag{
|
||||
Name: flagName,
|
||||
Value: field.Value().(string),
|
||||
Usage: flag.description,
|
||||
EnvVar: envName,
|
||||
}
|
||||
case reflect.Bool:
|
||||
results[i] = cli.BoolFlag{
|
||||
Name: flagName,
|
||||
Usage: flag.description,
|
||||
EnvVar: envName,
|
||||
}
|
||||
case reflect.Int:
|
||||
results[i] = cli.IntFlag{
|
||||
Name: flagName,
|
||||
Value: field.Value().(int),
|
||||
Usage: flag.description,
|
||||
EnvVar: envName,
|
||||
}
|
||||
default:
|
||||
return nil, errors.New("Unsupported type: " + fieldName)
|
||||
}
|
||||
}
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func applyFlags(
|
||||
options *app.Options,
|
||||
flags []flag,
|
||||
mappingHint map[string]string,
|
||||
c *cli.Context,
|
||||
) {
|
||||
o := structs.New(options)
|
||||
for _, flag := range flags {
|
||||
if c.IsSet(flag.name) {
|
||||
field := o.Field(fieldName(flag.name, mappingHint))
|
||||
var val interface{}
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
val = c.String(flag.name)
|
||||
case reflect.Bool:
|
||||
val = c.Bool(flag.name)
|
||||
case reflect.Int:
|
||||
val = c.Int(flag.name)
|
||||
}
|
||||
field.Set(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fieldName(name string, hint map[string]string) string {
|
||||
if fieldName, ok := hint[name]; ok {
|
||||
return fieldName
|
||||
}
|
||||
nameParts := strings.Split(name, "-")
|
||||
for i, part := range nameParts {
|
||||
nameParts[i] = strings.ToUpper(part[0:1]) + part[1:]
|
||||
}
|
||||
return strings.Join(nameParts, "")
|
||||
}
|
22
go.mod
Normal file
@ -0,0 +1,22 @@
|
||||
module github.com/sorenisanerd/gotty
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/NYTimes/gziphandler v1.1.1
|
||||
github.com/creack/pty v1.1.11
|
||||
github.com/fatih/structs v1.1.0
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/urfave/cli/v2 v2.3.0
|
||||
github.com/yudai/hcl v0.0.0-20151013225006-5fa2393b3552
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
|
||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.0.1 // indirect
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
golang.org/x/sys v0.1.0 // indirect
|
||||
)
|
36
go.sum
Normal file
@ -0,0 +1,36 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
|
||||
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
|
||||
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/yudai/hcl v0.0.0-20151013225006-5fa2393b3552 h1:tjsK9T2IA3d2FFNxzDP7AJf+EXhyuPd7PB4Z2HrtAoc=
|
||||
github.com/yudai/hcl v0.0.0-20151013225006-5fa2393b3552/go.mod h1:hg0ZaCmQL3rze1cH8Fh2g0a9q8vQs0uN8ESpePEwSEw=
|
||||
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
19
help.go
@ -1,19 +0,0 @@
|
||||
package main
|
||||
|
||||
var helpTemplate = `NAME:
|
||||
{{.Name}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.Name}} [options] <command> [<arguments...>]
|
||||
|
||||
VERSION:
|
||||
{{.Version}}{{if or .Author .Email}}
|
||||
|
||||
AUTHOR:{{if .Author}}
|
||||
{{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
|
||||
{{.Email}}{{end}}{{end}}
|
||||
|
||||
OPTIONS:
|
||||
{{range .Flags}}{{.}}
|
||||
{{end}}
|
||||
`
|
4524
js/package-lock.json
generated
Normal file
34
js/package.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "gotty",
|
||||
"version": "1.4.0",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@types/bootstrap": "^5.2.10",
|
||||
"compression-webpack-plugin": "^9.2.0",
|
||||
"license-loader": "^0.5.0",
|
||||
"license-webpack-plugin": "^4.0.2",
|
||||
"purgecss": "^4.1.3",
|
||||
"sass": "^1.70.0",
|
||||
"sass-loader": "^12.6.0",
|
||||
"terser-webpack-plugin": "^5.3.10",
|
||||
"ts-loader": "^8.4.0",
|
||||
"typescript": "^4.9.5",
|
||||
"webpack": "^5.90.1",
|
||||
"webpack-cli": "^4.10.0",
|
||||
"webpack-dev-server": "^4.15.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"bootstrap": "^5.3.2",
|
||||
"css-loader": "^5.2.7",
|
||||
"debounce": "^1.2.1",
|
||||
"preact": "^10.19.4",
|
||||
"react-bootstrap": "^2.10.1",
|
||||
"style-loader": "^2.0.0",
|
||||
"xterm": "^5.3.0",
|
||||
"xterm-addon-fit": "^0.8.0",
|
||||
"xterm-addon-web-links": "^0.9.0",
|
||||
"xterm-addon-webgl": "^0.16.0",
|
||||
"zmodem.js": "^0.1.10"
|
||||
}
|
||||
}
|
63
js/src/MyModal.tsx
Normal file
@ -0,0 +1,63 @@
|
||||
import { createRef, Component, ComponentChildren } from "preact";
|
||||
import { Modal } from "bootstrap";
|
||||
import './bootstrap.scss';
|
||||
|
||||
interface ModalProps {
|
||||
children: ComponentChildren;
|
||||
buttons?: ComponentChildren;
|
||||
title: string;
|
||||
dismissHandler?: (hideModal?: () => void) => void;
|
||||
}
|
||||
|
||||
export class MyModal extends Component<ModalProps, {}> {
|
||||
ref = createRef<HTMLDivElement>();
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
Modal.getOrCreateInstance(this.ref.current!).show();
|
||||
this.ref.current?.addEventListener('hide.bs.modal', () => { this.props.dismissHandler && this.props.dismissHandler(); });
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.hide()
|
||||
}
|
||||
|
||||
hide(): void {
|
||||
Modal.getOrCreateInstance(this.ref.current!).hide();
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div class="modal fade" ref={this.ref} tabIndex={-1} aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">{this.props.title}</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{this.props.children}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
{this.props.buttons}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
interface ButtonProps {
|
||||
priority: "primary" | "secondary" | "danger"
|
||||
clickHandler?: () => void
|
||||
children: ComponentChildren
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function Button(props:ButtonProps) {
|
||||
let classes: string = "btn btn-" + props.priority
|
||||
|
||||
return <button type="button" disabled={props.disabled} class={classes} onClick={ () => { props.clickHandler ? props.clickHandler() : null; }}>{ props.children}</button>
|
||||
}
|
26
js/src/bootstrap.scss
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
@import "mixins/banner";
|
||||
@include bsBanner("");
|
||||
|
||||
|
||||
// scss-docs-start import-stack
|
||||
// Configuration
|
||||
@import "functions";
|
||||
@import "variables";
|
||||
@import "variables-dark";
|
||||
@import "maps";
|
||||
@import "mixins";
|
||||
@import "utilities";
|
||||
|
||||
// Layout & components
|
||||
@import "root";
|
||||
@import "reboot";
|
||||
@import "type";
|
||||
@import "images";
|
||||
@import "containers";
|
||||
@import "grid";
|
||||
@import "buttons";
|
||||
@import "transitions";
|
||||
@import "progress";
|
||||
@import "close";
|
||||
@import "modal";
|
||||
@import "spinners";
|
31
js/src/main.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { ConnectionFactory } from "./websocket";
|
||||
import { Terminal, WebTTY, protocols } from "./webtty";
|
||||
import { OurXterm } from "./xterm";
|
||||
|
||||
// @TODO remove these
|
||||
declare var gotty_auth_token: string;
|
||||
declare var gotty_term: string;
|
||||
declare var gotty_ws_query_args: string;
|
||||
|
||||
const elem = document.getElementById("terminal")
|
||||
|
||||
if (elem !== null) {
|
||||
var term: Terminal;
|
||||
term = new OurXterm(elem);
|
||||
|
||||
const httpsEnabled = window.location.protocol == "https:";
|
||||
const queryArgs = (gotty_ws_query_args === "") ? "" : "?" + gotty_ws_query_args;
|
||||
const url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws' + queryArgs;
|
||||
const args = window.location.search;
|
||||
const factory = new ConnectionFactory(url, protocols);
|
||||
const wt = new WebTTY(term, factory, args, gotty_auth_token);
|
||||
const closer = wt.open();
|
||||
|
||||
// According to https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event
|
||||
// this event is unreliable and in some cases (Firefox is mentioned), having an
|
||||
// "unload" event handler can have unwanted side effects. Consider commenting it out.
|
||||
window.addEventListener("unload", () => {
|
||||
closer();
|
||||
term.close();
|
||||
});
|
||||
};
|
59
js/src/websocket.ts
Normal file
@ -0,0 +1,59 @@
|
||||
export class ConnectionFactory {
|
||||
url: string;
|
||||
protocols: string[];
|
||||
|
||||
constructor(url: string, protocols: string[]) {
|
||||
this.url = url;
|
||||
this.protocols = protocols;
|
||||
};
|
||||
|
||||
create(): Connection {
|
||||
return new Connection(this.url, this.protocols);
|
||||
};
|
||||
}
|
||||
|
||||
export class Connection {
|
||||
bare: WebSocket;
|
||||
|
||||
constructor(url: string, protocols: string[]) {
|
||||
this.bare = new WebSocket(url, protocols);
|
||||
}
|
||||
|
||||
open() {
|
||||
// nothing todo for websocket
|
||||
};
|
||||
|
||||
close() {
|
||||
this.bare.close();
|
||||
};
|
||||
|
||||
send(data: string) {
|
||||
this.bare.send(data);
|
||||
};
|
||||
|
||||
isOpen(): boolean {
|
||||
if (this.bare.readyState == WebSocket.CONNECTING ||
|
||||
this.bare.readyState == WebSocket.OPEN) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
onOpen(callback: () => void) {
|
||||
this.bare.onopen = (event) => {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
onReceive(callback: (data: string) => void) {
|
||||
this.bare.onmessage = (event) => {
|
||||
callback(event.data);
|
||||
}
|
||||
};
|
||||
|
||||
onClose(callback: () => void) {
|
||||
this.bare.onclose = (event) => {
|
||||
callback();
|
||||
};
|
||||
};
|
||||
}
|
270
js/src/webtty.tsx
Normal file
@ -0,0 +1,270 @@
|
||||
export const protocols = ["webtty"];
|
||||
|
||||
export const msgInputUnknown = '0';
|
||||
export const msgInput = '1';
|
||||
export const msgPing = '2';
|
||||
export const msgResizeTerminal = '3';
|
||||
export const msgSetEncoding = '4';
|
||||
|
||||
export const msgUnknownOutput = '0';
|
||||
export const msgOutput = '1';
|
||||
export const msgPong = '2';
|
||||
export const msgSetWindowTitle = '3';
|
||||
export const msgSetPreferences = '4';
|
||||
export const msgSetReconnect = '5';
|
||||
export const msgSetBufferSize = '6';
|
||||
|
||||
|
||||
export interface Terminal {
|
||||
/*
|
||||
* Get dimensions of the terminal
|
||||
*/
|
||||
info(): { columns: number, rows: number };
|
||||
|
||||
/*
|
||||
* Process output from the server side
|
||||
*/
|
||||
output(data: Uint8Array): void;
|
||||
|
||||
/*
|
||||
* Display a message overlay on the terminal
|
||||
*/
|
||||
showMessage(message: string, timeout: number): void;
|
||||
|
||||
// Don't think we need this anymore
|
||||
// getMessage(): HTMLElement;
|
||||
|
||||
/*
|
||||
* Remove message shown by shoMessage. You only need to call
|
||||
* this if you want to dismiss it sooner than the timeout.
|
||||
*/
|
||||
removeMessage(): void;
|
||||
|
||||
|
||||
/*
|
||||
* Set window title
|
||||
*/
|
||||
setWindowTitle(title: string): void;
|
||||
|
||||
/*
|
||||
* Set preferences. TODO: Add typings
|
||||
*/
|
||||
setPreferences(value: object): void;
|
||||
|
||||
|
||||
/*
|
||||
* Sets an input (e.g. user types something) handler
|
||||
*/
|
||||
onInput(callback: (input: string) => void): void;
|
||||
|
||||
/*
|
||||
* Sets a resize handler
|
||||
*/
|
||||
onResize(callback: (colmuns: number, rows: number) => void): void;
|
||||
|
||||
reset(): void;
|
||||
deactivate(): void;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
export interface Connection {
|
||||
open(): void;
|
||||
close(): void;
|
||||
|
||||
/*
|
||||
* This takes fucking strings??
|
||||
*/
|
||||
send(s: string): void;
|
||||
|
||||
isOpen(): boolean;
|
||||
onOpen(callback: () => void): void;
|
||||
onReceive(callback: (data: string) => void): void;
|
||||
onClose(callback: () => void): void;
|
||||
}
|
||||
|
||||
export interface ConnectionFactory {
|
||||
create(): Connection;
|
||||
}
|
||||
|
||||
export class WebTTY {
|
||||
/*
|
||||
* A terminal instance that implements the Terminal interface.
|
||||
* This made a lot of sense when we had both HTerm and xterm, but
|
||||
* now I wonder if the abstraction makes sense. Keeping it for now,
|
||||
* though.
|
||||
*/
|
||||
term: Terminal;
|
||||
|
||||
/*
|
||||
* ConnectionFactory and connection instance. We pass the factory
|
||||
* in instead of just a connection so that we can reconnect.
|
||||
*/
|
||||
connectionFactory: ConnectionFactory;
|
||||
connection: Connection;
|
||||
|
||||
/*
|
||||
* Arguments passed in by the user. We forward them to the backend
|
||||
* where they are appended to the command line.
|
||||
*/
|
||||
args: string;
|
||||
|
||||
/*
|
||||
* An authentication token. The client gets this from `/auth_token.js`.
|
||||
*/
|
||||
authToken: string;
|
||||
|
||||
/*
|
||||
* If connection is dropped, reconnect after `reconnect` seconds.
|
||||
* -1 means do not reconnect.
|
||||
*/
|
||||
reconnect: number;
|
||||
|
||||
/*
|
||||
* The server's buffer size. If a single message exceeds this size, it will
|
||||
* be truncated on the server, so we track it here so that we can split messages
|
||||
* into chunks small enough that we don't hurt the server's feelings.
|
||||
*/
|
||||
bufSize: number;
|
||||
|
||||
constructor(term: Terminal, connectionFactory: ConnectionFactory, args: string, authToken: string) {
|
||||
this.term = term;
|
||||
this.connectionFactory = connectionFactory;
|
||||
this.args = args;
|
||||
this.authToken = authToken;
|
||||
this.reconnect = -1;
|
||||
this.bufSize = 1024;
|
||||
};
|
||||
|
||||
open() {
|
||||
let connection = this.connectionFactory.create();
|
||||
let pingTimer: NodeJS.Timeout;
|
||||
let reconnectTimeout: NodeJS.Timeout;
|
||||
this.connection = connection;
|
||||
|
||||
const setup = () => {
|
||||
connection.onOpen(() => {
|
||||
const termInfo = this.term.info();
|
||||
|
||||
this.initializeConnection(this.args, this.authToken);
|
||||
|
||||
this.term.onResize((columns: number, rows: number) => {
|
||||
this.sendResizeTerminal(columns, rows);
|
||||
});
|
||||
|
||||
this.sendResizeTerminal(termInfo.columns, termInfo.rows);
|
||||
|
||||
this.sendSetEncoding("base64");
|
||||
|
||||
this.term.onInput(
|
||||
(input: string | Uint8Array) => {
|
||||
this.sendInput(input);
|
||||
}
|
||||
);
|
||||
|
||||
pingTimer = setInterval(() => {
|
||||
this.sendPing()
|
||||
}, 30 * 1000);
|
||||
});
|
||||
|
||||
connection.onReceive((data) => {
|
||||
const payload = data.slice(1);
|
||||
switch (data[0]) {
|
||||
case msgOutput:
|
||||
this.term.output(Uint8Array.from(atob(payload), c => c.charCodeAt(0)));
|
||||
break;
|
||||
case msgPong:
|
||||
break;
|
||||
case msgSetWindowTitle:
|
||||
this.term.setWindowTitle(payload);
|
||||
break;
|
||||
case msgSetPreferences:
|
||||
const preferences = JSON.parse(payload);
|
||||
this.term.setPreferences(preferences);
|
||||
break;
|
||||
case msgSetReconnect:
|
||||
const autoReconnect = JSON.parse(payload);
|
||||
console.log("Enabling reconnect: " + autoReconnect + " seconds")
|
||||
this.reconnect = autoReconnect;
|
||||
break;
|
||||
case msgSetBufferSize:
|
||||
const bufSize = JSON.parse(payload);
|
||||
this.bufSize = bufSize;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
connection.onClose(() => {
|
||||
clearInterval(pingTimer);
|
||||
this.term.deactivate();
|
||||
this.term.showMessage("Connection Closed", 0);
|
||||
if (this.reconnect > 0) {
|
||||
reconnectTimeout = setTimeout(() => {
|
||||
connection = this.connectionFactory.create();
|
||||
this.term.reset();
|
||||
setup();
|
||||
}, this.reconnect * 1000);
|
||||
}
|
||||
});
|
||||
|
||||
connection.open();
|
||||
}
|
||||
|
||||
setup();
|
||||
return () => {
|
||||
clearTimeout(reconnectTimeout);
|
||||
connection.close();
|
||||
}
|
||||
};
|
||||
|
||||
private initializeConnection(args, authToken) {
|
||||
this.connection.send(JSON.stringify(
|
||||
{
|
||||
Arguments: args,
|
||||
AuthToken: authToken,
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
* sendInput sends data to the server. It accepts strings or Uint8Arrays.
|
||||
* strings will be encoded as UTF-8. Uint8Arrays are passed along as-is.
|
||||
*/
|
||||
private sendInput(input: string | Uint8Array) {
|
||||
let effectiveBufferSize = this.bufSize - 1;
|
||||
let dataString: string;
|
||||
|
||||
if (typeof input === "string") {
|
||||
dataString = input;
|
||||
} else {
|
||||
dataString = String.fromCharCode(...input)
|
||||
}
|
||||
|
||||
// Account for base64 encoding
|
||||
let maxChunkSize = Math.floor(effectiveBufferSize / 4) * 3;
|
||||
|
||||
for (let i = 0; i < Math.ceil(dataString.length / maxChunkSize); i++) {
|
||||
let inputChunk = dataString.substring(i * maxChunkSize, Math.min((i + 1) * maxChunkSize, dataString.length))
|
||||
this.connection.send(msgInput + btoa(inputChunk));
|
||||
}
|
||||
}
|
||||
|
||||
private sendPing(): void {
|
||||
this.connection.send(msgPing);
|
||||
}
|
||||
|
||||
private sendResizeTerminal(colmuns: number, rows: number) {
|
||||
this.connection.send(
|
||||
msgResizeTerminal + JSON.stringify(
|
||||
{
|
||||
columns: colmuns,
|
||||
rows: rows
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private sendSetEncoding(encoding: "base64" | "null") {
|
||||
this.connection.send(msgSetEncoding + encoding)
|
||||
}
|
||||
|
||||
};
|
166
js/src/xterm.tsx
Normal file
@ -0,0 +1,166 @@
|
||||
import { IDisposable, Terminal } from "xterm";
|
||||
import { FitAddon } from 'xterm-addon-fit';
|
||||
import { WebLinksAddon } from 'xterm-addon-web-links';
|
||||
import { WebglAddon } from 'xterm-addon-webgl';
|
||||
import { ZModemAddon } from "./zmodem";
|
||||
|
||||
export class OurXterm {
|
||||
// The HTMLElement that contains our terminal
|
||||
elem: HTMLElement;
|
||||
|
||||
// The xtermjs.XTerm
|
||||
term: Terminal;
|
||||
|
||||
resizeListener: () => void;
|
||||
|
||||
message: HTMLElement;
|
||||
messageTimeout: number;
|
||||
messageTimer: NodeJS.Timeout;
|
||||
|
||||
onResizeHandler: IDisposable;
|
||||
onDataHandler: IDisposable;
|
||||
|
||||
fitAddOn: FitAddon;
|
||||
zmodemAddon: ZModemAddon;
|
||||
toServer: (data: string | Uint8Array) => void;
|
||||
encoder: TextEncoder
|
||||
|
||||
constructor(elem: HTMLElement) {
|
||||
this.elem = elem;
|
||||
this.term = new Terminal();
|
||||
this.fitAddOn = new FitAddon();
|
||||
this.zmodemAddon = new ZModemAddon({
|
||||
toTerminal: (x: Uint8Array) => this.term.write(x),
|
||||
toServer: (x: Uint8Array) => this.sendInput(x)
|
||||
});
|
||||
this.term.loadAddon(new WebLinksAddon());
|
||||
this.term.loadAddon(this.fitAddOn);
|
||||
this.term.loadAddon(this.zmodemAddon);
|
||||
|
||||
this.message = elem.ownerDocument.createElement("div");
|
||||
this.message.className = "xterm-overlay";
|
||||
this.messageTimeout = 2000;
|
||||
|
||||
this.resizeListener = () => {
|
||||
this.fitAddOn.fit();
|
||||
this.term.scrollToBottom();
|
||||
this.showMessage(String(this.term.cols) + "x" + String(this.term.rows), this.messageTimeout);
|
||||
};
|
||||
|
||||
this.term.open(elem);
|
||||
this.term.focus();
|
||||
this.resizeListener();
|
||||
|
||||
window.addEventListener("resize", () => { this.resizeListener(); });
|
||||
};
|
||||
|
||||
info(): { columns: number, rows: number } {
|
||||
return { columns: this.term.cols, rows: this.term.rows };
|
||||
};
|
||||
|
||||
// This gets called from the Websocket's onReceive handler
|
||||
output(data: Uint8Array) {
|
||||
this.zmodemAddon.consume(data);
|
||||
};
|
||||
|
||||
getMessage(): HTMLElement {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
showMessage(message: string, timeout: number) {
|
||||
this.message.innerHTML = message;
|
||||
this.showMessageElem(timeout);
|
||||
}
|
||||
|
||||
showMessageElem(timeout: number) {
|
||||
this.elem.appendChild(this.message);
|
||||
|
||||
if (this.messageTimer) {
|
||||
clearTimeout(this.messageTimer);
|
||||
}
|
||||
if (timeout > 0) {
|
||||
this.messageTimer = setTimeout(() => {
|
||||
try {
|
||||
this.elem.removeChild(this.message);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}, timeout);
|
||||
}
|
||||
};
|
||||
|
||||
removeMessage(): void {
|
||||
if (this.message.parentNode == this.elem) {
|
||||
this.elem.removeChild(this.message);
|
||||
}
|
||||
}
|
||||
|
||||
setWindowTitle(title: string) {
|
||||
document.title = title;
|
||||
};
|
||||
|
||||
setPreferences(value: object) {
|
||||
Object.keys(value).forEach((key) => {
|
||||
if (key == "EnableWebGL" && key) {
|
||||
this.term.loadAddon(new WebglAddon());
|
||||
} else if (key == "font-size") {
|
||||
this.term.options.fontSize = value[key]
|
||||
} else if (key == "font-family") {
|
||||
this.term.options.fontFamily = value[key]
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
sendInput(data: Uint8Array) {
|
||||
return this.toServer(data)
|
||||
}
|
||||
|
||||
onInput(callback: (input: string) => void) {
|
||||
this.encoder = new TextEncoder()
|
||||
this.toServer = callback;
|
||||
|
||||
// I *think* we're ok like this, but if not, we can dispose
|
||||
// of the previous handler and put the new one in place.
|
||||
if (this.onDataHandler !== undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
this.onDataHandler = this.term.onData((input) => {
|
||||
this.toServer(this.encoder.encode(input));
|
||||
});
|
||||
};
|
||||
|
||||
onResize(callback: (colmuns: number, rows: number) => void) {
|
||||
this.onResizeHandler = this.term.onResize(() => {
|
||||
callback(this.term.cols, this.term.rows);
|
||||
});
|
||||
};
|
||||
|
||||
deactivate(): void {
|
||||
this.onDataHandler.dispose();
|
||||
this.onResizeHandler.dispose();
|
||||
this.term.blur();
|
||||
}
|
||||
|
||||
reset(): void {
|
||||
this.removeMessage();
|
||||
this.term.clear();
|
||||
}
|
||||
|
||||
close(): void {
|
||||
window.removeEventListener("resize", this.resizeListener);
|
||||
this.term.dispose();
|
||||
}
|
||||
|
||||
disableStdin(): void {
|
||||
this.term.options.disableStdin = true;
|
||||
}
|
||||
|
||||
enableStdin(): void {
|
||||
this.term.options.disableStdin = false;
|
||||
}
|
||||
|
||||
focus(): void {
|
||||
this.term.focus();
|
||||
}
|
||||
}
|
245
js/src/zmodem.tsx
Normal file
@ -0,0 +1,245 @@
|
||||
import { Component, ComponentChildren, createRef, render } from "preact";
|
||||
import { ITerminalAddon, Terminal } from "xterm";
|
||||
import { Browser, Detection, Offer, Sentry, Session } from 'zmodem.js/src/zmodem_browser';
|
||||
import { Button, MyModal } from "./MyModal";
|
||||
|
||||
export class ZModemAddon implements ITerminalAddon {
|
||||
term: Terminal;
|
||||
elem: HTMLDivElement;
|
||||
sentry: Sentry;
|
||||
toTerminal: (data: Uint8Array) => void;
|
||||
toServer: (data: Uint8Array) => void;
|
||||
|
||||
constructor(props: {
|
||||
toTerminal: (data: Uint8Array) => void,
|
||||
toServer: (data: Uint8Array) => void
|
||||
}) {
|
||||
this.createElement();
|
||||
this.toTerminal = props.toTerminal;
|
||||
this.toServer = props.toServer;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
private createElement() {
|
||||
this.elem = document.createElement("div");
|
||||
document.body.prepend(this.elem);
|
||||
}
|
||||
|
||||
consume(data: Uint8Array) {
|
||||
this.sentry.consume(data)
|
||||
}
|
||||
|
||||
activate(terminal: Terminal): void {
|
||||
this.term = terminal
|
||||
}
|
||||
|
||||
dispose() {
|
||||
}
|
||||
|
||||
private init() {
|
||||
render(<></>, this.elem);
|
||||
|
||||
this.sentry = new Sentry({
|
||||
'to_terminal': (d: Uint8Array) => this.toTerminal(d),
|
||||
'on_detect': (detection: Detection) => this.onDetect(detection),
|
||||
'sender': (x: Uint8Array) => { this.toServer(x) },
|
||||
'on_retract': () => this.reset(),
|
||||
});
|
||||
}
|
||||
|
||||
private reset() {
|
||||
this.init();
|
||||
this.term.options.disableStdin = false;
|
||||
this.term.focus();
|
||||
}
|
||||
|
||||
private onDetect(detection: Detection) {
|
||||
var zsession = detection.confirm();
|
||||
|
||||
this.term.options.disableStdin = true;
|
||||
|
||||
zsession.on('session_end', () => { this.reset() });
|
||||
|
||||
if (zsession.type === "send") {
|
||||
this.send(zsession);
|
||||
}
|
||||
else {
|
||||
zsession.on("offer", (xfer: any) => this.onOffer(xfer));
|
||||
zsession.start();
|
||||
}
|
||||
}
|
||||
|
||||
private send(zsession: Session) {
|
||||
render(<SendFileModal session={zsession} />, this.elem)
|
||||
}
|
||||
|
||||
private onOffer(xfer: Offer) {
|
||||
render(<ReceiveFileModal xfer={xfer} onFinish={() => this.reset()} />, this.elem)
|
||||
}
|
||||
}
|
||||
|
||||
// Renders a bootstrap progress bar
|
||||
function Progress(props: { min: number, max: number, now: number, children?: ComponentChildren }) {
|
||||
let { min, max, now } = props;
|
||||
let percentage = "0";
|
||||
|
||||
if ((typeof min === "number") &&
|
||||
(typeof max === "number") &&
|
||||
(typeof now === "number") &&
|
||||
(min != max)) {
|
||||
percentage = (100 * (now - min) / (max - min)).toFixed(0);
|
||||
}
|
||||
|
||||
return <div class="progress">
|
||||
<div class="progress-bar" role="progressbar" style={"width: " + percentage + "%"} aria-valuenow={now} aria-valuemin={min} aria-valuemax={max}>{props.children}</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
interface ReceiveFileModalProps {
|
||||
xfer: Offer;
|
||||
onFinish?: () => void;
|
||||
}
|
||||
|
||||
interface ReceiveFileModalState {
|
||||
state: "notstarted" | "started" | "skipped" | "done"
|
||||
}
|
||||
|
||||
export class ReceiveFileModal extends Component<ReceiveFileModalProps, ReceiveFileModalState> {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.setState({ state: "notstarted" })
|
||||
}
|
||||
|
||||
accept() {
|
||||
this.setState({ state: "started" });
|
||||
|
||||
let timerID = setInterval(
|
||||
() => this.forceUpdate(),
|
||||
100
|
||||
);
|
||||
|
||||
this.props.xfer.accept().then((payloads: any) => {
|
||||
// All done, so stop updating the progress bar
|
||||
// and perform a final render.
|
||||
clearInterval(timerID);
|
||||
this.forceUpdate();
|
||||
|
||||
if (this.state.state != "skipped") {
|
||||
Browser.save_to_disk(
|
||||
payloads,
|
||||
this.props.xfer.get_details().name
|
||||
);
|
||||
}
|
||||
this.setState({ state: "done" })
|
||||
})
|
||||
}
|
||||
|
||||
finish() {
|
||||
console.log('finished');
|
||||
if (this.props.onFinish) this.props.onFinish();
|
||||
}
|
||||
|
||||
progress() {
|
||||
if (this.state.state !== "notstarted") {
|
||||
return <Progress min={0} max={this.props.xfer.get_details().size} now={this.props.xfer.get_offset()} />
|
||||
}
|
||||
}
|
||||
|
||||
skip() {
|
||||
this.props.xfer.skip()
|
||||
this.setState({ state: "skipped" })
|
||||
}
|
||||
|
||||
buttons() {
|
||||
switch (this.state.state) {
|
||||
case "notstarted":
|
||||
return <>
|
||||
<Button priority="primary" clickHandler={() => { this.accept(); }}>Accept</Button>
|
||||
<Button priority="secondary" clickHandler={() => { this.skip(); }}>Decline</Button>
|
||||
</>
|
||||
case "started":
|
||||
return <>
|
||||
<Button priority="danger" clickHandler={() => { this.skip(); }}>Cancel</Button>
|
||||
</>
|
||||
case "skipped":
|
||||
return <>
|
||||
<Button priority="danger" disabled={true}>Skipping...</Button>
|
||||
</>
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.state != "done")
|
||||
return <MyModal title="Incoming file"
|
||||
buttons={this.buttons()}>
|
||||
Accept <code>{this.props.xfer.get_details().name}</code> ({this.props.xfer.get_details().size.toLocaleString(undefined, { maximumFractionDigits: 0 })} bytes)?
|
||||
{this.progress()}
|
||||
</MyModal>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class SendFileModal extends Component<SendFileModalProps, SendFileModalState> {
|
||||
filePickerRef = createRef<HTMLInputElement>();
|
||||
|
||||
constructor(props: SendFileModalProps) {
|
||||
super(props)
|
||||
this.setState({ state: "notstarted" })
|
||||
}
|
||||
|
||||
buttons() {
|
||||
switch (this.state.state) {
|
||||
case "started":
|
||||
return <>
|
||||
<Button priority="primary" clickHandler={() => { this.send(); }} disabled={true}>
|
||||
Sending...
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
</Button>
|
||||
</>
|
||||
case "notstarted":
|
||||
return <>
|
||||
<Button priority="primary" clickHandler={() => { this.send(); }}>Send</Button>
|
||||
</>
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
send() {
|
||||
Browser.send_files(this.props.session,
|
||||
this.filePickerRef.current!.files, {
|
||||
on_offer_response: (f, xfer) => { this.setState({ state: "started" }) },
|
||||
}).then(() => {
|
||||
this.setState({ state: "done" })
|
||||
this.props.session.close()
|
||||
if (this.props.onFinish !== undefined) {
|
||||
this.props.onFinish();
|
||||
}
|
||||
})
|
||||
.catch(e => console.log(e));
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.state != "done")
|
||||
return <MyModal title="Send file(s)"
|
||||
buttons={this.buttons()}>
|
||||
<div class="mb-3">
|
||||
<label for="formFileMultiple" class="form-label">
|
||||
Remote requested file transfer
|
||||
</label>
|
||||
<input ref={this.filePickerRef} class="form-control form-control-sm" type="file" id="formFileMultiple" multiple />
|
||||
</div>
|
||||
</MyModal>
|
||||
}
|
||||
}
|
||||
|
||||
interface SendFileModalProps {
|
||||
onFinish?: () => void;
|
||||
session: Session;
|
||||
}
|
||||
|
||||
interface SendFileModalState {
|
||||
state: "notstarted" | "started" | "done"
|
||||
currentFile: any
|
||||
}
|
24
js/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/",
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact",
|
||||
"strictNullChecks": true,
|
||||
"noUnusedLocals" : true,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"target": "esnext",
|
||||
"module": "commonJS",
|
||||
"baseUrl": ".",
|
||||
"types": ["preact", "node"],
|
||||
"paths": {
|
||||
"*": ["./typings/*"]
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist"
|
||||
]
|
||||
}
|
57
js/webpack.config.js
Normal file
@ -0,0 +1,57 @@
|
||||
const path = require('path');
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
|
||||
|
||||
var devtool;
|
||||
|
||||
if (process.env.DEV === '1') {
|
||||
devtool = 'inline-source-map';
|
||||
} else {
|
||||
devtool = 'source-map';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
entry: "./src/main.ts",
|
||||
entry: {
|
||||
"gotty": "./src/main.ts",
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, '../bindata/static/js/'),
|
||||
},
|
||||
devtool: devtool,
|
||||
resolve: {
|
||||
extensions: [".ts", ".tsx", ".js"],
|
||||
},
|
||||
plugins: [
|
||||
new LicenseWebpackPlugin()
|
||||
],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
loader: "ts-loader",
|
||||
exclude: /node_modules/
|
||||
},
|
||||
{
|
||||
test: /\.css$/i,
|
||||
use: ["style-loader", "css-loader"],
|
||||
},
|
||||
{
|
||||
test: /\.scss$/i,
|
||||
use: ["style-loader", "css-loader", {
|
||||
loader: "sass-loader",
|
||||
options: {
|
||||
sassOptions: {
|
||||
includePaths: ["node_modules/bootstrap/scss"]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [new TerserPlugin()],
|
||||
},
|
||||
};
|
1
libapps
@ -1 +0,0 @@
|
||||
Subproject commit 9dc111b58c7e5af86c1b3a0cb3b04a22a8dcf584
|
176
main.go
@ -1,118 +1,125 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
cli "github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/yudai/gotty/app"
|
||||
"github.com/sorenisanerd/gotty/backend/localcommand"
|
||||
"github.com/sorenisanerd/gotty/pkg/homedir"
|
||||
"github.com/sorenisanerd/gotty/server"
|
||||
"github.com/sorenisanerd/gotty/utils"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cmd := cli.NewApp()
|
||||
cmd.Version = app.Version
|
||||
cmd.Name = "gotty"
|
||||
cmd.Usage = "Share your terminal as a web application"
|
||||
cmd.HideHelp = true
|
||||
app := cli.NewApp()
|
||||
app.Name = "gotty"
|
||||
app.Version = Version
|
||||
app.Usage = "Share your terminal as a web application"
|
||||
app.HideHelpCommand = true
|
||||
appOptions := &server.Options{}
|
||||
|
||||
flags := []flag{
|
||||
flag{"address", "a", "IP address to listen"},
|
||||
flag{"port", "p", "Port number to listen"},
|
||||
flag{"permit-write", "w", "Permit clients to write to the TTY (BE CAREFUL)"},
|
||||
flag{"credential", "c", "Credential for Basic Authentication (ex: user:pass, default disabled)"},
|
||||
flag{"random-url", "r", "Add a random string to the URL"},
|
||||
flag{"random-url-length", "", "Random URL length"},
|
||||
flag{"tls", "t", "Enable TLS/SSL"},
|
||||
flag{"tls-crt", "", "TLS/SSL certificate file path"},
|
||||
flag{"tls-key", "", "TLS/SSL key file path"},
|
||||
flag{"tls-ca-crt", "", "TLS/SSL CA certificate file for client certifications"},
|
||||
flag{"index", "", "Custom index.html file"},
|
||||
flag{"title-format", "", "Title format of browser window"},
|
||||
flag{"reconnect", "", "Enable reconnection"},
|
||||
flag{"reconnect-time", "", "Time to reconnect"},
|
||||
flag{"timeout", "", "Timeout seconds for waiting a client (0 to disable)"},
|
||||
flag{"max-connection", "", "Maximum connection to gotty, 0(default) means no limit"},
|
||||
flag{"once", "", "Accept only one client and exit on disconnection"},
|
||||
flag{"permit-arguments", "", "Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB)"},
|
||||
flag{"close-signal", "", "Signal sent to the command process when gotty close it (default: SIGHUP)"},
|
||||
flag{"width", "", "Static width of the screen, 0(default) means dynamically resize"},
|
||||
flag{"height", "", "Static height of the screen, 0(default) means dynamically resize"},
|
||||
if err := utils.ApplyDefaultValues(appOptions); err != nil {
|
||||
exit(err, 1)
|
||||
}
|
||||
backendOptions := &localcommand.Options{}
|
||||
if err := utils.ApplyDefaultValues(backendOptions); err != nil {
|
||||
exit(err, 1)
|
||||
}
|
||||
|
||||
mappingHint := map[string]string{
|
||||
"index": "IndexFile",
|
||||
"tls": "EnableTLS",
|
||||
"tls-crt": "TLSCrtFile",
|
||||
"tls-key": "TLSKeyFile",
|
||||
"tls-ca-crt": "TLSCACrtFile",
|
||||
"random-url": "EnableRandomUrl",
|
||||
"reconnect": "EnableReconnect",
|
||||
}
|
||||
|
||||
cliFlags, err := generateFlags(flags, mappingHint)
|
||||
cliFlags, flagMappings, err := utils.GenerateFlags(appOptions, backendOptions)
|
||||
if err != nil {
|
||||
exit(err, 3)
|
||||
}
|
||||
|
||||
cmd.Flags = append(
|
||||
app.Flags = append(
|
||||
cliFlags,
|
||||
cli.StringFlag{
|
||||
Name: "config",
|
||||
Value: "~/.gotty",
|
||||
Usage: "Config file path",
|
||||
EnvVar: "GOTTY_CONFIG",
|
||||
&cli.StringFlag{
|
||||
Name: "config",
|
||||
Value: "~/.gotty",
|
||||
Usage: "Config file path",
|
||||
EnvVars: []string{"GOTTY_CONFIG"},
|
||||
},
|
||||
)
|
||||
|
||||
cmd.Action = func(c *cli.Context) {
|
||||
if len(c.Args()) == 0 {
|
||||
fmt.Println("Error: No command given.\n")
|
||||
app.Action = func(c *cli.Context) error {
|
||||
if c.NArg() == 0 {
|
||||
msg := "Error: No command given."
|
||||
cli.ShowAppHelp(c)
|
||||
exit(err, 1)
|
||||
exit(fmt.Errorf(msg), 1)
|
||||
}
|
||||
|
||||
options := app.DefaultOptions
|
||||
|
||||
configFile := c.String("config")
|
||||
_, err := os.Stat(app.ExpandHomeDir(configFile))
|
||||
_, err := os.Stat(homedir.Expand(configFile))
|
||||
if configFile != "~/.gotty" || !os.IsNotExist(err) {
|
||||
if err := app.ApplyConfigFile(&options, configFile); err != nil {
|
||||
if err := utils.ApplyConfigFile(configFile, appOptions, backendOptions); err != nil {
|
||||
exit(err, 2)
|
||||
}
|
||||
}
|
||||
|
||||
applyFlags(&options, flags, mappingHint, c)
|
||||
utils.ApplyFlags(cliFlags, flagMappings, c, appOptions, backendOptions)
|
||||
|
||||
if appOptions.Quiet {
|
||||
log.SetFlags(0)
|
||||
log.SetOutput(io.Discard)
|
||||
}
|
||||
|
||||
if c.IsSet("credential") {
|
||||
options.EnableBasicAuth = true
|
||||
appOptions.EnableBasicAuth = true
|
||||
}
|
||||
if c.IsSet("tls-ca-crt") {
|
||||
options.EnableTLSClientAuth = true
|
||||
appOptions.EnableTLSClientAuth = true
|
||||
}
|
||||
|
||||
if err := app.CheckConfig(&options); err != nil {
|
||||
err = appOptions.Validate()
|
||||
if err != nil {
|
||||
exit(err, 6)
|
||||
}
|
||||
|
||||
app, err := app.New(c.Args(), &options)
|
||||
args := c.Args()
|
||||
factory, err := localcommand.NewFactory(args.First(), args.Tail(), backendOptions)
|
||||
if err != nil {
|
||||
exit(err, 3)
|
||||
}
|
||||
|
||||
registerSignals(app)
|
||||
|
||||
err = app.Run()
|
||||
if err != nil {
|
||||
exit(err, 4)
|
||||
hostname, _ := os.Hostname()
|
||||
appOptions.TitleVariables = map[string]interface{}{
|
||||
"command": args.First(),
|
||||
"argv": args.Tail(),
|
||||
"hostname": hostname,
|
||||
}
|
||||
|
||||
srv, err := server.New(factory, appOptions)
|
||||
if err != nil {
|
||||
exit(err, 3)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
gCtx, gCancel := context.WithCancel(context.Background())
|
||||
|
||||
log.Printf("GoTTY is starting with command: %s", strings.Join(args.Slice(), " "))
|
||||
|
||||
errs := make(chan error, 1)
|
||||
go func() {
|
||||
errs <- srv.Run(ctx, server.WithGracefullContext(gCtx))
|
||||
}()
|
||||
err = waitSignals(errs, cancel, gCancel)
|
||||
|
||||
if err != nil && err != context.Canceled {
|
||||
fmt.Printf("Error: %s\n", err)
|
||||
exit(err, 8)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
cli.AppHelpTemplate = helpTemplate
|
||||
|
||||
cmd.Run(os.Args)
|
||||
app.Run(os.Args)
|
||||
}
|
||||
|
||||
func exit(err error, code int) {
|
||||
@ -122,7 +129,7 @@ func exit(err error, code int) {
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
func registerSignals(app *app.App) {
|
||||
func waitSignals(errs chan error, cancel context.CancelFunc, gracefullCancel context.CancelFunc) error {
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(
|
||||
sigChan,
|
||||
@ -130,17 +137,26 @@ func registerSignals(app *app.App) {
|
||||
syscall.SIGTERM,
|
||||
)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
s := <-sigChan
|
||||
switch s {
|
||||
case syscall.SIGINT, syscall.SIGTERM:
|
||||
if app.Exit() {
|
||||
fmt.Println("Send ^C to force exit.")
|
||||
} else {
|
||||
os.Exit(5)
|
||||
}
|
||||
select {
|
||||
case err := <-errs:
|
||||
return err
|
||||
|
||||
case s := <-sigChan:
|
||||
switch s {
|
||||
case syscall.SIGINT:
|
||||
gracefullCancel()
|
||||
fmt.Println("C-C to force close")
|
||||
select {
|
||||
case err := <-errs:
|
||||
return err
|
||||
case <-sigChan:
|
||||
fmt.Println("Force closing...")
|
||||
cancel()
|
||||
return <-errs
|
||||
}
|
||||
default:
|
||||
cancel()
|
||||
return <-errs
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
13
pkg/homedir/expand.go
Normal file
@ -0,0 +1,13 @@
|
||||
package homedir
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func Expand(path string) string {
|
||||
if path[0:2] == "~/" {
|
||||
return os.Getenv("HOME") + path[1:]
|
||||
} else {
|
||||
return path
|
||||
}
|
||||
}
|
18
pkg/randomstring/generate.go
Normal file
@ -0,0 +1,18 @@
|
||||
package randomstring
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Generate(length int) string {
|
||||
const base = 36
|
||||
size := big.NewInt(base)
|
||||
n := make([]byte, length)
|
||||
for i, _ := range n {
|
||||
c, _ := rand.Int(rand.Reader, size)
|
||||
n[i] = strconv.FormatInt(c.Int64(), base)[0]
|
||||
}
|
||||
return string(n)
|
||||
}
|
8
release-checklist.md
Normal file
@ -0,0 +1,8 @@
|
||||
* Check that the build works, duh.
|
||||
* Check that "gotty bash" works and that it does not accept input.
|
||||
* Check that "gotty -w bash" works and that it DOES accept input.
|
||||
* Check that "gotty -w bash" works and that it DOES accept input.
|
||||
* Check that cross-compilation works.
|
||||
* Ensure NEWS is up-to-date
|
||||
* Ensure contributor list is up-to-date
|
||||
* Ensure usage is correct in Makefile
|
BIN
resources/favicon.ico
Normal file
After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 863 B |
@ -1,96 +0,0 @@
|
||||
(function() {
|
||||
var httpsEnabled = window.location.protocol == "https:";
|
||||
var args = window.location.search;
|
||||
var url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws';
|
||||
var protocols = ["gotty"];
|
||||
var autoReconnect = -1;
|
||||
|
||||
var openWs = function() {
|
||||
var ws = new WebSocket(url, protocols);
|
||||
|
||||
var term;
|
||||
|
||||
var pingTimer;
|
||||
|
||||
ws.onopen = function(event) {
|
||||
ws.send(JSON.stringify({ Arguments: args, AuthToken: gotty_auth_token,}));
|
||||
pingTimer = setInterval(sendPing, 30 * 1000, ws);
|
||||
|
||||
hterm.defaultStorage = new lib.Storage.Local();
|
||||
hterm.defaultStorage.clear();
|
||||
|
||||
term = new hterm.Terminal();
|
||||
|
||||
term.getPrefs().set("send-encoding", "raw");
|
||||
|
||||
term.onTerminalReady = function() {
|
||||
var io = term.io.push();
|
||||
|
||||
io.onVTKeystroke = function(str) {
|
||||
ws.send("0" + str);
|
||||
};
|
||||
|
||||
io.sendString = io.onVTKeystroke;
|
||||
|
||||
io.onTerminalResize = function(columns, rows) {
|
||||
ws.send(
|
||||
"2" + JSON.stringify(
|
||||
{
|
||||
columns: columns,
|
||||
rows: rows,
|
||||
}
|
||||
)
|
||||
)
|
||||
};
|
||||
|
||||
term.installKeyboard();
|
||||
};
|
||||
|
||||
term.decorate(document.getElementById("terminal"));
|
||||
};
|
||||
|
||||
ws.onmessage = function(event) {
|
||||
data = event.data.slice(1);
|
||||
switch(event.data[0]) {
|
||||
case '0':
|
||||
term.io.writeUTF8(window.atob(data));
|
||||
break;
|
||||
case '1':
|
||||
// pong
|
||||
break;
|
||||
case '2':
|
||||
term.setWindowTitle(data);
|
||||
break;
|
||||
case '3':
|
||||
preferences = JSON.parse(data);
|
||||
Object.keys(preferences).forEach(function(key) {
|
||||
console.log("Setting " + key + ": " + preferences[key]);
|
||||
term.getPrefs().set(key, preferences[key]);
|
||||
});
|
||||
break;
|
||||
case '4':
|
||||
autoReconnect = JSON.parse(data);
|
||||
console.log("Enabling reconnect: " + autoReconnect + " seconds")
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = function(event) {
|
||||
if (term) {
|
||||
term.uninstallKeyboard();
|
||||
term.io.showOverlay("Connection Closed", null);
|
||||
}
|
||||
clearInterval(pingTimer);
|
||||
if (autoReconnect > 0) {
|
||||
setTimeout(openWs, autoReconnect * 1000);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var sendPing = function(ws) {
|
||||
ws.send("1");
|
||||
}
|
||||
|
||||
openWs();
|
||||
})()
|
66
resources/icon.svg
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 708.4149 708.41411"
|
||||
height="708.41412"
|
||||
width="708.41492"
|
||||
xml:space="preserve"
|
||||
id="svg2"
|
||||
version="1.1"><metadata
|
||||
id="metadata8"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs6"><clipPath
|
||||
id="clipPath18"
|
||||
clipPathUnits="userSpaceOnUse"><path
|
||||
id="path16"
|
||||
d="M 0,2000 H 2000 V 0 H 0 Z" /></clipPath></defs><g
|
||||
transform="matrix(1.3333333,0,0,-1.3333333,-979.12558,1687.5405)"
|
||||
id="g10"><g
|
||||
id="g12"><g
|
||||
clip-path="url(#clipPath18)"
|
||||
id="g14"><g
|
||||
transform="translate(772.1414,1265.6554)"
|
||||
id="g20"><path
|
||||
id="path22"
|
||||
style="fill:#de3c28;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 c -20.875,0 -37.797,-16.922 -37.797,-37.797 v -126.348 -25.917 -212.342 L 345.882,0 Z" /></g><g
|
||||
transform="translate(956.8504,734.3448)"
|
||||
id="g24"><path
|
||||
id="path26"
|
||||
style="fill:#af1419;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 h 260.209 c 26.839,0 48.596,21.757 48.596,48.596 v 275.281 z" /></g><g
|
||||
transform="translate(1265.6552,1075.5929)"
|
||||
id="g28"><path
|
||||
id="path30"
|
||||
style="fill:#db0918;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 v 25.918 126.348 c 0,20.875 -16.922,37.796 -37.796,37.796 h -109.836 l -383.679,-402.404 v -80.31 c 0,-26.839 21.757,-48.596 48.596,-48.596 h 173.91 L 0,-17.371 Z" /></g><g
|
||||
transform="translate(1169.2147,909.6954)"
|
||||
id="g32"><path
|
||||
id="path34"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 h -138.227 c -9.129,0 -16.528,7.4 -16.528,16.529 0,9.128 7.399,16.529 16.528,16.529 H 0 c 9.129,0 16.528,-7.401 16.528,-16.529 C 16.528,7.4 9.129,0 0,0" /></g><g
|
||||
transform="translate(898.8318,1033.5314)"
|
||||
id="g36"><path
|
||||
id="path38"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 c 2.86,-0.72 5.65,-1.45 8.37,-2.2 -0.63,-8.56 -7.76,-15.3 -16.479,-15.3 -9.13,0 -16.531,7.4 -16.531,16.53 v 8.54 c 1.861,-0.83 3.72,-1.549 5.601,-2.15 C -15.199,4.18 -8.85,2.37 0,0" /></g><g
|
||||
transform="translate(907.2527,1150.7814)"
|
||||
id="g40"><path
|
||||
id="path42"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 v -65.81 c -4.45,1.59 -9.98,2.38 -16.601,2.38 -6.21,0 -11.7,-0.88 -16.46,-2.64 V 0 c 0,9.13 7.401,16.53 16.531,16.53 C -7.4,16.53 0,9.13 0,0" /></g><g
|
||||
transform="translate(874.1922,868.8272)"
|
||||
id="g44"><path
|
||||
id="path46"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 v 65.811 c 4.45,-1.59 9.98,-2.38 16.601,-2.38 6.21,0 11.699,0.88 16.46,2.639 V 0 C 33.061,-9.13 25.66,-16.529 16.53,-16.529 7.4,-16.529 0,-9.13 0,0" /></g><g
|
||||
transform="translate(966.6326,994.1915)"
|
||||
id="g48"><path
|
||||
id="path50"
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
d="m 0,0 c -3.53,7.28 -8.45,13.3 -14.75,18.06 -6.301,4.76 -13.95,8.8 -22.94,12.14 -6.661,2.47 -13.911,4.78 -21.741,6.94 -2.719,0.75 -5.509,1.48 -8.37,2.2 -8.849,2.37 -15.199,4.18 -19.039,5.42 -1.881,0.6 -3.74,1.32 -5.6,2.15 -1.951,0.87 -3.88,1.87 -5.8,2.99 -3.76,2.19 -6.71,4.81 -8.861,7.85 -2.139,3.05 -3.219,6.67 -3.219,10.86 0,6.75 3.16,12.54 9.46,17.34 2.49,1.9 5.299,3.43 8.42,4.57 4.759,1.76 10.25,2.64 16.46,2.64 6.62,0 12.15,-0.79 16.6,-2.38 3.01,-1.05 5.52,-2.48 7.54,-4.26 5.01,-4.42 9.3,-10.59 12.88,-18.49 2.77,-5.52 5.34,-9.49 7.71,-11.92 2.37,-2.43 5.84,-3.64 10.399,-3.64 5.011,0 9.191,2.02 12.54,6.07 3.351,4.04 5.031,8.59 5.031,13.63 0,5.52 -1.34,11.19 -4.021,17 -2.689,5.8 -6.939,11.35 -12.75,16.63 -5.809,5.28 -13.119,9.52 -21.929,12.71 -5.23,1.89 -11.031,3.22 -17.4,3.99 -4.37,0.53 -9.011,0.79 -13.921,0.79 -6.779,0 -13.159,-0.48 -19.139,-1.45 -7.361,-1.19 -14.121,-3.11 -20.29,-5.76 -11.18,-4.81 -19.72,-11.69 -25.621,-20.63 -5.899,-8.95 -8.849,-19.18 -8.849,-30.7 0,-12.09 2.79,-22.2 8.38,-30.34 5.59,-8.14 13.15,-14.56 22.67,-19.28 9.52,-4.71 21.349,-8.83 35.48,-12.35 10.55,-2.57 18.98,-4.99 25.279,-7.28 6.301,-2.28 11.441,-5.59 15.42,-9.92 3.981,-4.33 5.971,-9.97 5.971,-16.92 0,-8.76 -3.69,-16.06 -11.061,-21.92 -7.379,-5.85 -16.969,-8.78 -28.769,-8.78 -8.59,0 -15.521,1.45 -20.79,4.36 -5.28,2.9 -9.37,6.59 -12.28,11.06 -2.901,4.47 -5.611,10.04 -8.111,16.71 -2.059,5.61 -4.54,9.85 -7.449,12.7 -2.9,2.86 -6.46,4.29 -10.66,4.29 -5.181,0 -9.45,-1.84 -12.811,-5.5 -3.349,-3.66 -5.029,-8.07 -5.029,-13.21 0,-8.85 2.8,-17.96 8.39,-27.34 5.58,-9.38 12.849,-16.87 21.79,-22.49 12.61,-7.8 28.61,-11.7 48.019,-11.7 16.181,0 30.181,2.85 41.981,8.56 11.809,5.71 20.769,13.61 26.9,23.7 6.119,10.09 9.18,21.47 9.18,34.129 C 5.3,-16.21 3.54,-7.28 0,0" /></g></g></g></g></svg>
|
After Width: | Height: | Size: 5.3 KiB |
BIN
resources/icon_192.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
13
resources/index.css
Normal file
@ -0,0 +1,13 @@
|
||||
html, body, #terminal {
|
||||
background: black;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
padding: 0%;
|
||||
margin: 0%;
|
||||
}
|
||||
|
||||
.progress .progress-bar {
|
||||
transition: unset;
|
||||
transition-duration: 0.1s;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
@ -1,14 +1,22 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>GoTTY</title>
|
||||
<style>body, #terminal {position: absolute; height: 100%; width: 100%; margin: 0px;}</style>
|
||||
<link rel="icon" type="image/png" href="favicon.png">
|
||||
</head>
|
||||
<body>
|
||||
<div id="terminal"></div>
|
||||
<script src="./js/hterm.js"></script>
|
||||
<script src="./auth_token.js"></script>
|
||||
<script src="./js/gotty.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<head>
|
||||
<title>{{ .title }}</title>
|
||||
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
|
||||
<link rel="icon" href="favicon.ico">
|
||||
<link rel="icon" href="icon.svg" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="./css/index.css" />
|
||||
<link rel="stylesheet" href="./css/xterm.css" />
|
||||
<link rel="stylesheet" href="./css/xterm_customize.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="terminal"></div>
|
||||
<script src="./auth_token.js"></script>
|
||||
<script src="./config.js"></script>
|
||||
<script src="./js/gotty.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
15
resources/manifest.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"short_name": "{{ .title }}",
|
||||
"name": "{{ .title }}",
|
||||
"start_url": "./",
|
||||
"icons": [
|
||||
{
|
||||
"src": "./icon_192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
}
|
||||
],
|
||||
"display": "minimal-ui",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#000000"
|
||||
}
|
19
resources/xterm_customize.css
Normal file
@ -0,0 +1,19 @@
|
||||
.terminal {
|
||||
font-family: "DejaVu Sans Mono", "Everson Mono", FreeMono, Menlo, Terminal, monospace, "Apple Symbols";
|
||||
}
|
||||
|
||||
.xterm-overlay {
|
||||
font-family: "DejaVu Sans Mono", "Everson Mono", FreeMono, Menlo, Terminal, monospace, "Apple Symbols";
|
||||
border-radius: 15px;
|
||||
font-size: xx-large;
|
||||
color: black;
|
||||
background: white;
|
||||
opacity: 0.75;
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
user-select: none;
|
||||
transition: opacity 180ms ease-in;
|
||||
}
|
70
server/handler_atomic.go
Normal file
@ -0,0 +1,70 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type counter struct {
|
||||
duration time.Duration
|
||||
zeroTimer *time.Timer
|
||||
wg sync.WaitGroup
|
||||
connections int
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
func newCounter(duration time.Duration) *counter {
|
||||
zeroTimer := time.NewTimer(duration)
|
||||
|
||||
// when duration is 0, drain the expire event here
|
||||
// so that user will never get the event.
|
||||
if duration == 0 {
|
||||
<-zeroTimer.C
|
||||
}
|
||||
|
||||
return &counter{
|
||||
duration: duration,
|
||||
zeroTimer: zeroTimer,
|
||||
}
|
||||
}
|
||||
|
||||
func (counter *counter) add(n int) int {
|
||||
counter.mutex.Lock()
|
||||
defer counter.mutex.Unlock()
|
||||
|
||||
if counter.duration > 0 {
|
||||
counter.zeroTimer.Stop()
|
||||
}
|
||||
counter.wg.Add(n)
|
||||
counter.connections += n
|
||||
|
||||
return counter.connections
|
||||
}
|
||||
|
||||
func (counter *counter) done() int {
|
||||
counter.mutex.Lock()
|
||||
defer counter.mutex.Unlock()
|
||||
|
||||
counter.connections--
|
||||
counter.wg.Done()
|
||||
if counter.connections == 0 && counter.duration > 0 {
|
||||
counter.zeroTimer.Reset(counter.duration)
|
||||
}
|
||||
|
||||
return counter.connections
|
||||
}
|
||||
|
||||
func (counter *counter) count() int {
|
||||
counter.mutex.Lock()
|
||||
defer counter.mutex.Unlock()
|
||||
|
||||
return counter.connections
|
||||
}
|
||||
|
||||
func (counter *counter) wait() {
|
||||
counter.wg.Wait()
|
||||
}
|
||||
|
||||
func (counter *counter) timer() *time.Timer {
|
||||
return counter.zeroTimer
|
||||
}
|
266
server/handlers.go
Normal file
@ -0,0 +1,266 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/sorenisanerd/gotty/webtty"
|
||||
)
|
||||
|
||||
func (server *Server) generateHandleWS(ctx context.Context, cancel context.CancelFunc, counter *counter) http.HandlerFunc {
|
||||
once := new(int64)
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-counter.timer().C:
|
||||
cancel()
|
||||
case <-ctx.Done():
|
||||
}
|
||||
}()
|
||||
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if server.options.Once {
|
||||
success := atomic.CompareAndSwapInt64(once, 0, 1)
|
||||
if !success {
|
||||
http.Error(w, "Server is shutting down", http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
num := counter.add(1)
|
||||
closeReason := "unknown reason"
|
||||
|
||||
defer func() {
|
||||
num := counter.done()
|
||||
log.Printf(
|
||||
"Connection closed by %s: %s, connections: %d/%d",
|
||||
closeReason, r.RemoteAddr, num, server.options.MaxConnection,
|
||||
)
|
||||
|
||||
if server.options.Once {
|
||||
cancel()
|
||||
}
|
||||
}()
|
||||
|
||||
if int64(server.options.MaxConnection) != 0 {
|
||||
if num > server.options.MaxConnection {
|
||||
closeReason = "exceeding max number of connections"
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("New client connected: %s, connections: %d/%d", r.RemoteAddr, num, server.options.MaxConnection)
|
||||
|
||||
if r.Method != "GET" {
|
||||
http.Error(w, "Method not allowed", 405)
|
||||
return
|
||||
}
|
||||
|
||||
conn, err := server.upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
closeReason = err.Error()
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
if server.options.PassHeaders {
|
||||
err = server.processWSConn(ctx, conn, r.Header)
|
||||
} else {
|
||||
err = server.processWSConn(ctx, conn, nil)
|
||||
}
|
||||
|
||||
switch err {
|
||||
case ctx.Err():
|
||||
closeReason = "cancelation"
|
||||
case webtty.ErrSlaveClosed:
|
||||
closeReason = server.factory.Name()
|
||||
case webtty.ErrMasterClosed:
|
||||
closeReason = "client"
|
||||
default:
|
||||
closeReason = fmt.Sprintf("an error: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (server *Server) processWSConn(ctx context.Context, conn *websocket.Conn, headers map[string][]string) error {
|
||||
typ, initLine, err := conn.ReadMessage()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to authenticate websocket connection")
|
||||
}
|
||||
if typ != websocket.TextMessage {
|
||||
return errors.New("failed to authenticate websocket connection: invalid message type")
|
||||
}
|
||||
|
||||
var init InitMessage
|
||||
err = json.Unmarshal(initLine, &init)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to authenticate websocket connection")
|
||||
}
|
||||
if init.AuthToken != server.options.Credential {
|
||||
return errors.New("failed to authenticate websocket connection")
|
||||
}
|
||||
|
||||
queryPath := "?"
|
||||
if server.options.PermitArguments && init.Arguments != "" {
|
||||
queryPath = init.Arguments
|
||||
}
|
||||
|
||||
query, err := url.Parse(queryPath)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to parse arguments")
|
||||
}
|
||||
params := query.Query()
|
||||
var slave Slave
|
||||
slave, err = server.factory.New(params, headers)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create backend")
|
||||
}
|
||||
defer slave.Close()
|
||||
|
||||
titleVars := server.titleVariables(
|
||||
[]string{"server", "master", "slave"},
|
||||
map[string]map[string]interface{}{
|
||||
"server": server.options.TitleVariables,
|
||||
"master": map[string]interface{}{
|
||||
"remote_addr": conn.RemoteAddr(),
|
||||
},
|
||||
"slave": slave.WindowTitleVariables(),
|
||||
},
|
||||
)
|
||||
|
||||
titleBuf := new(bytes.Buffer)
|
||||
err = server.titleTemplate.Execute(titleBuf, titleVars)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to fill window title template")
|
||||
}
|
||||
|
||||
opts := []webtty.Option{
|
||||
webtty.WithWindowTitle(titleBuf.Bytes()),
|
||||
}
|
||||
if server.options.PermitWrite {
|
||||
opts = append(opts, webtty.WithPermitWrite())
|
||||
}
|
||||
if server.options.EnableReconnect {
|
||||
opts = append(opts, webtty.WithReconnect(server.options.ReconnectTime))
|
||||
}
|
||||
if server.options.Width > 0 {
|
||||
opts = append(opts, webtty.WithFixedColumns(server.options.Width))
|
||||
}
|
||||
if server.options.Height > 0 {
|
||||
opts = append(opts, webtty.WithFixedRows(server.options.Height))
|
||||
}
|
||||
tty, err := webtty.New(&wsWrapper{conn}, slave, opts...)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create webtty")
|
||||
}
|
||||
|
||||
err = tty.Run(ctx)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (server *Server) handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
indexVars, err := server.indexVariables(r)
|
||||
if err != nil {
|
||||
http.Error(w, "Internal Server Error", 500)
|
||||
return
|
||||
}
|
||||
|
||||
indexBuf := new(bytes.Buffer)
|
||||
err = server.indexTemplate.Execute(indexBuf, indexVars)
|
||||
if err != nil {
|
||||
http.Error(w, "Internal Server Error", 500)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write(indexBuf.Bytes())
|
||||
}
|
||||
|
||||
func (server *Server) handleManifest(w http.ResponseWriter, r *http.Request) {
|
||||
indexVars, err := server.indexVariables(r)
|
||||
if err != nil {
|
||||
http.Error(w, "Internal Server Error", 500)
|
||||
return
|
||||
}
|
||||
|
||||
indexBuf := new(bytes.Buffer)
|
||||
err = server.manifestTemplate.Execute(indexBuf, indexVars)
|
||||
if err != nil {
|
||||
http.Error(w, "Internal Server Error", 500)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write(indexBuf.Bytes())
|
||||
}
|
||||
|
||||
func (server *Server) indexVariables(r *http.Request) (map[string]interface{}, error) {
|
||||
titleVars := server.titleVariables(
|
||||
[]string{"server", "master"},
|
||||
map[string]map[string]interface{}{
|
||||
"server": server.options.TitleVariables,
|
||||
"master": map[string]interface{}{
|
||||
"remote_addr": r.RemoteAddr,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
titleBuf := new(bytes.Buffer)
|
||||
err := server.titleTemplate.Execute(titleBuf, titleVars)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
indexVars := map[string]interface{}{
|
||||
"title": titleBuf.String(),
|
||||
}
|
||||
return indexVars, err
|
||||
}
|
||||
|
||||
func (server *Server) handleAuthToken(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
// @TODO hashing?
|
||||
w.Write([]byte("var gotty_auth_token = '" + server.options.Credential + "';"))
|
||||
}
|
||||
|
||||
func (server *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
lines := []string{
|
||||
"var gotty_term = 'xterm';",
|
||||
"var gotty_ws_query_args = '" + server.options.WSQueryArgs + "';",
|
||||
}
|
||||
|
||||
w.Write([]byte(strings.Join(lines, "\n")))
|
||||
}
|
||||
|
||||
// titleVariables merges maps in a specified order.
|
||||
// varUnits are name-keyed maps, whose names will be iterated using order.
|
||||
func (server *Server) titleVariables(order []string, varUnits map[string]map[string]interface{}) map[string]interface{} {
|
||||
titleVars := map[string]interface{}{}
|
||||
|
||||
for _, name := range order {
|
||||
vars, ok := varUnits[name]
|
||||
if !ok {
|
||||
panic("title variable name error")
|
||||
}
|
||||
for key, val := range vars {
|
||||
titleVars[key] = val
|
||||
}
|
||||
}
|
||||
|
||||
// safe net for conflicted keys
|
||||
for _, name := range order {
|
||||
titleVars[name] = varUnits[name]
|
||||
}
|
||||
|
||||
return titleVars
|
||||
}
|
6
server/init_message.go
Normal file
@ -0,0 +1,6 @@
|
||||
package server
|
||||
|
||||
type InitMessage struct {
|
||||
Arguments string `json:"Arguments,omitempty"`
|
||||
AuthToken string `json:"AuthToken,omitempty"`
|
||||
}
|
28
server/list_address.go
Normal file
@ -0,0 +1,28 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func listAddresses() (addresses []string) {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
addresses = make([]string, 0, len(ifaces))
|
||||
|
||||
for _, iface := range ifaces {
|
||||
ifAddrs, _ := iface.Addrs()
|
||||
for _, ifAddr := range ifAddrs {
|
||||
switch v := ifAddr.(type) {
|
||||
case *net.IPNet:
|
||||
addresses = append(addresses, v.IP.String())
|
||||
case *net.IPAddr:
|
||||
addresses = append(addresses, v.IP.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return addresses
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package app
|
||||
package server
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@ -6,17 +6,17 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type responseWrapper struct {
|
||||
type logResponseWriter struct {
|
||||
http.ResponseWriter
|
||||
status int
|
||||
}
|
||||
|
||||
func (w *responseWrapper) WriteHeader(status int) {
|
||||
func (w *logResponseWriter) WriteHeader(status int) {
|
||||
w.status = status
|
||||
w.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
func (w *responseWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
func (w *logResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
hj, _ := w.ResponseWriter.(http.Hijacker)
|
||||
w.status = http.StatusSwitchingProtocols
|
||||
return hj.Hijack()
|
51
server/middleware.go
Normal file
@ -0,0 +1,51 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (server *Server) wrapLogger(handler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
rw := &logResponseWriter{w, 200}
|
||||
handler.ServeHTTP(rw, r)
|
||||
log.Printf("%s %d %s %s", r.RemoteAddr, rw.status, r.Method, r.URL.Path)
|
||||
})
|
||||
}
|
||||
|
||||
func (server *Server) wrapHeaders(handler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// todo add version
|
||||
w.Header().Set("Server", "GoTTY")
|
||||
handler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func (server *Server) wrapBasicAuth(handler http.Handler, credential string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
token := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
|
||||
|
||||
if len(token) != 2 || strings.ToLower(token[0]) != "basic" {
|
||||
w.Header().Set("WWW-Authenticate", `Basic realm="GoTTY"`)
|
||||
http.Error(w, "Bad Request", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
payload, err := base64.StdEncoding.DecodeString(token[1])
|
||||
if err != nil {
|
||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if credential != string(payload) {
|
||||
w.Header().Set("WWW-Authenticate", `Basic realm="GoTTY"`)
|
||||
http.Error(w, "authorization failed", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Basic Authentication Succeeded: %s", r.RemoteAddr)
|
||||
handler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
45
server/options.go
Normal file
@ -0,0 +1,45 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Address string `hcl:"address" flagName:"address" flagSName:"a" flagDescribe:"IP address to listen" default:"0.0.0.0"`
|
||||
Port string `hcl:"port" flagName:"port" flagSName:"p" flagDescribe:"Port number to liten" default:"8080"`
|
||||
Path string `hcl:"path" flagName:"path" flagSName:"m" flagDescribe:"Base path" default:"/"`
|
||||
PermitWrite bool `hcl:"permit_write" flagName:"permit-write" flagSName:"w" flagDescribe:"Permit clients to write to the TTY (BE CAREFUL)" default:"false"`
|
||||
EnableBasicAuth bool `hcl:"enable_basic_auth" default:"false"`
|
||||
Credential string `hcl:"credential" flagName:"credential" flagSName:"c" flagDescribe:"Credential for Basic Authentication (ex: user:pass, default disabled)" default:""`
|
||||
EnableRandomUrl bool `hcl:"enable_random_url" flagName:"random-url" flagSName:"r" flagDescribe:"Add a random string to the URL" default:"false"`
|
||||
RandomUrlLength int `hcl:"random_url_length" flagName:"random-url-length" flagDescribe:"Random URL length" default:"8"`
|
||||
EnableTLS bool `hcl:"enable_tls" flagName:"tls" flagSName:"t" flagDescribe:"Enable TLS/SSL" default:"false"`
|
||||
TLSCrtFile string `hcl:"tls_crt_file" flagName:"tls-crt" flagDescribe:"TLS/SSL certificate file path" default:"~/.gotty.crt"`
|
||||
TLSKeyFile string `hcl:"tls_key_file" flagName:"tls-key" flagDescribe:"TLS/SSL key file path" default:"~/.gotty.key"`
|
||||
EnableTLSClientAuth bool `hcl:"enable_tls_client_auth" default:"false"`
|
||||
TLSCACrtFile string `hcl:"tls_ca_crt_file" flagName:"tls-ca-crt" flagDescribe:"TLS/SSL CA certificate file for client certifications" default:"~/.gotty.ca.crt"`
|
||||
IndexFile string `hcl:"index_file" flagName:"index" flagDescribe:"Custom index.html file" default:""`
|
||||
TitleFormat string `hcl:"title_format" flagName:"title-format" flagSName:"" flagDescribe:"Title format of browser window" default:"{{ .command }}@{{ .hostname }}"`
|
||||
EnableReconnect bool `hcl:"enable_reconnect" flagName:"reconnect" flagDescribe:"Enable reconnection" default:"false"`
|
||||
ReconnectTime int `hcl:"reconnect_time" flagName:"reconnect-time" flagDescribe:"Time to reconnect" default:"10"`
|
||||
MaxConnection int `hcl:"max_connection" flagName:"max-connection" flagDescribe:"Maximum connection to gotty" default:"0"`
|
||||
Once bool `hcl:"once" flagName:"once" flagDescribe:"Accept only one client and exit on disconnection" default:"false"`
|
||||
Timeout int `hcl:"timeout" flagName:"timeout" flagDescribe:"Timeout seconds for waiting a client(0 to disable)" default:"0"`
|
||||
PermitArguments bool `hcl:"permit_arguments" flagName:"permit-arguments" flagDescribe:"Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB)" default:"false"`
|
||||
PassHeaders bool `hcl:"pass_headers" flagName:"pass-headers" flagDescribe:"Pass HTTP request headers as environment variables (e.g. Cookie becomes HTTP_COOKIE)" default:"false"`
|
||||
Width int `hcl:"width" flagName:"width" flagDescribe:"Static width of the screen, 0(default) means dynamically resize" default:"0"`
|
||||
Height int `hcl:"height" flagName:"height" flagDescribe:"Static height of the screen, 0(default) means dynamically resize" default:"0"`
|
||||
WSOrigin string `hcl:"ws_origin" flagName:"ws-origin" flagDescribe:"A regular expression that matches origin URLs to be accepted by WebSocket. No cross origin requests are acceptable by default" default:""`
|
||||
WSQueryArgs string `hcl:"ws_query_args" flagName:"ws-query-args" flagDescribe:"Querystring arguments to append to the websocket instantiation" default:""`
|
||||
EnableWebGL bool `hcl:"enable_webgl" flagName:"enable-webgl" flagDescribe:"Enable WebGL renderer" default:"true"`
|
||||
Quiet bool `hcl:"quiet" flagName:"quiet" flagDescribe:"Don't log" default:"false"`
|
||||
|
||||
TitleVariables map[string]interface{}
|
||||
}
|
||||
|
||||
func (options *Options) Validate() error {
|
||||
if options.EnableTLSClientAuth && !options.EnableTLS {
|
||||
return errors.New("TLS client authentication is enabled, but TLS is not enabled")
|
||||
}
|
||||
return nil
|
||||
}
|
21
server/run_option.go
Normal file
@ -0,0 +1,21 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// RunOptions holds a set of configurations for Server.Run().
|
||||
type RunOptions struct {
|
||||
gracefullCtx context.Context
|
||||
}
|
||||
|
||||
// RunOption is an option of Server.Run().
|
||||
type RunOption func(*RunOptions)
|
||||
|
||||
// WithGracefullContext accepts a context to shutdown a Server
|
||||
// with care for existing client connections.
|
||||
func WithGracefullContext(ctx context.Context) RunOption {
|
||||
return func(options *RunOptions) {
|
||||
options.gracefullCtx = ctx
|
||||
}
|
||||
}
|
269
server/server.go
Normal file
@ -0,0 +1,269 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
noesctmpl "text/template"
|
||||
"time"
|
||||
|
||||
"github.com/NYTimes/gziphandler"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/sorenisanerd/gotty/bindata"
|
||||
"github.com/sorenisanerd/gotty/pkg/homedir"
|
||||
"github.com/sorenisanerd/gotty/pkg/randomstring"
|
||||
"github.com/sorenisanerd/gotty/webtty"
|
||||
)
|
||||
|
||||
// Server provides a webtty HTTP endpoint.
|
||||
type Server struct {
|
||||
factory Factory
|
||||
options *Options
|
||||
|
||||
upgrader *websocket.Upgrader
|
||||
indexTemplate *template.Template
|
||||
titleTemplate *noesctmpl.Template
|
||||
manifestTemplate *template.Template
|
||||
}
|
||||
|
||||
// New creates a new instance of Server.
|
||||
// Server will use the New() of the factory provided to handle each request.
|
||||
func New(factory Factory, options *Options) (*Server, error) {
|
||||
indexData, err := bindata.Fs.ReadFile("static/index.html")
|
||||
if err != nil {
|
||||
panic("index not found") // must be in bindata
|
||||
}
|
||||
if options.IndexFile != "" {
|
||||
path := homedir.Expand(options.IndexFile)
|
||||
indexData, err = os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to read custom index file at `%s`", path)
|
||||
}
|
||||
}
|
||||
indexTemplate, err := template.New("index").Parse(string(indexData))
|
||||
if err != nil {
|
||||
panic("index template parse failed") // must be valid
|
||||
}
|
||||
|
||||
manifestData, err := bindata.Fs.ReadFile("static/manifest.json")
|
||||
if err != nil {
|
||||
panic("manifest not found") // must be in bindata
|
||||
}
|
||||
manifestTemplate, err := template.New("manifest").Parse(string(manifestData))
|
||||
if err != nil {
|
||||
panic("manifest template parse failed") // must be valid
|
||||
}
|
||||
|
||||
titleTemplate, err := noesctmpl.New("title").Parse(options.TitleFormat)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to parse window title format `%s`", options.TitleFormat)
|
||||
}
|
||||
|
||||
var originChekcer func(r *http.Request) bool
|
||||
if options.WSOrigin != "" {
|
||||
matcher, err := regexp.Compile(options.WSOrigin)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to compile regular expression of Websocket Origin: %s", options.WSOrigin)
|
||||
}
|
||||
originChekcer = func(r *http.Request) bool {
|
||||
return matcher.MatchString(r.Header.Get("Origin"))
|
||||
}
|
||||
}
|
||||
|
||||
return &Server{
|
||||
factory: factory,
|
||||
options: options,
|
||||
|
||||
upgrader: &websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
Subprotocols: webtty.Protocols,
|
||||
CheckOrigin: originChekcer,
|
||||
},
|
||||
indexTemplate: indexTemplate,
|
||||
titleTemplate: titleTemplate,
|
||||
manifestTemplate: manifestTemplate,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Run starts the main process of the Server.
|
||||
// The cancelation of ctx will shutdown the server immediately with aborting
|
||||
// existing connections. Use WithGracefullContext() to support gracefull shutdown.
|
||||
func (server *Server) Run(ctx context.Context, options ...RunOption) error {
|
||||
cctx, cancel := context.WithCancel(ctx)
|
||||
opts := &RunOptions{gracefullCtx: context.Background()}
|
||||
for _, opt := range options {
|
||||
opt(opts)
|
||||
}
|
||||
|
||||
counter := newCounter(time.Duration(server.options.Timeout) * time.Second)
|
||||
|
||||
path := server.options.Path
|
||||
if server.options.EnableRandomUrl {
|
||||
path = "/" + randomstring.Generate(server.options.RandomUrlLength) + "/"
|
||||
}
|
||||
if !strings.HasPrefix(path, "/") {
|
||||
path = "/" + path
|
||||
}
|
||||
if !strings.HasSuffix(path, "/") {
|
||||
path = path + "/"
|
||||
}
|
||||
handlers := server.setupHandlers(cctx, cancel, path, counter)
|
||||
srv, err := server.setupHTTPServer(handlers)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to setup an HTTP server")
|
||||
}
|
||||
|
||||
if server.options.PermitWrite {
|
||||
log.Printf("Permitting clients to write input to the PTY.")
|
||||
}
|
||||
if server.options.Once {
|
||||
log.Printf("Once option is provided, accepting only one client")
|
||||
}
|
||||
|
||||
if server.options.Port == "0" {
|
||||
log.Printf("Port number configured to `0`, choosing a random port")
|
||||
}
|
||||
hostPort := net.JoinHostPort(server.options.Address, server.options.Port)
|
||||
listener, err := net.Listen("tcp", hostPort)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to listen at `%s`", hostPort)
|
||||
}
|
||||
|
||||
scheme := "http"
|
||||
if server.options.EnableTLS {
|
||||
scheme = "https"
|
||||
}
|
||||
host, port, _ := net.SplitHostPort(listener.Addr().String())
|
||||
log.Printf("HTTP server is listening at: %s", scheme+"://"+net.JoinHostPort(host, port)+path)
|
||||
if server.options.Address == "0.0.0.0" {
|
||||
for _, address := range listAddresses() {
|
||||
log.Printf("Alternative URL: %s", scheme+"://"+net.JoinHostPort(address, port)+path)
|
||||
}
|
||||
}
|
||||
|
||||
srvErr := make(chan error, 1)
|
||||
go func() {
|
||||
if server.options.EnableTLS {
|
||||
crtFile := homedir.Expand(server.options.TLSCrtFile)
|
||||
keyFile := homedir.Expand(server.options.TLSKeyFile)
|
||||
log.Printf("TLS crt file: " + crtFile)
|
||||
log.Printf("TLS key file: " + keyFile)
|
||||
|
||||
err = srv.ServeTLS(listener, crtFile, keyFile)
|
||||
} else {
|
||||
err = srv.Serve(listener)
|
||||
}
|
||||
if err != nil {
|
||||
srvErr <- err
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
select {
|
||||
case <-opts.gracefullCtx.Done():
|
||||
srv.Shutdown(context.Background())
|
||||
case <-cctx.Done():
|
||||
}
|
||||
}()
|
||||
|
||||
select {
|
||||
case err = <-srvErr:
|
||||
if err == http.ErrServerClosed { // by gracefull ctx
|
||||
err = nil
|
||||
} else {
|
||||
cancel()
|
||||
}
|
||||
case <-cctx.Done():
|
||||
srv.Close()
|
||||
err = cctx.Err()
|
||||
}
|
||||
|
||||
conn := counter.count()
|
||||
if conn > 0 {
|
||||
log.Printf("Waiting for %d connections to be closed", conn)
|
||||
}
|
||||
counter.wait()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (server *Server) setupHandlers(ctx context.Context, cancel context.CancelFunc, pathPrefix string, counter *counter) http.Handler {
|
||||
fs, err := fs.Sub(bindata.Fs, "static")
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open static/ subdirectory of embedded filesystem: %v", err)
|
||||
}
|
||||
staticFileHandler := http.FileServer(http.FS(fs))
|
||||
|
||||
var siteMux = http.NewServeMux()
|
||||
siteMux.HandleFunc(pathPrefix, server.handleIndex)
|
||||
siteMux.Handle(pathPrefix+"js/", http.StripPrefix(pathPrefix, staticFileHandler))
|
||||
siteMux.Handle(pathPrefix+"favicon.ico", http.StripPrefix(pathPrefix, staticFileHandler))
|
||||
siteMux.Handle(pathPrefix+"icon.svg", http.StripPrefix(pathPrefix, staticFileHandler))
|
||||
siteMux.Handle(pathPrefix+"css/", http.StripPrefix(pathPrefix, staticFileHandler))
|
||||
siteMux.Handle(pathPrefix+"icon_192.png", http.StripPrefix(pathPrefix, staticFileHandler))
|
||||
|
||||
siteMux.HandleFunc(pathPrefix+"manifest.json", server.handleManifest)
|
||||
siteMux.HandleFunc(pathPrefix+"auth_token.js", server.handleAuthToken)
|
||||
siteMux.HandleFunc(pathPrefix+"config.js", server.handleConfig)
|
||||
|
||||
siteHandler := http.Handler(siteMux)
|
||||
|
||||
if server.options.EnableBasicAuth {
|
||||
log.Printf("Using Basic Authentication")
|
||||
siteHandler = server.wrapBasicAuth(siteHandler, server.options.Credential)
|
||||
}
|
||||
|
||||
withGz := gziphandler.GzipHandler(server.wrapHeaders(siteHandler))
|
||||
siteHandler = server.wrapLogger(withGz)
|
||||
|
||||
wsMux := http.NewServeMux()
|
||||
wsMux.Handle("/", siteHandler)
|
||||
wsMux.HandleFunc(pathPrefix+"ws", server.generateHandleWS(ctx, cancel, counter))
|
||||
siteHandler = http.Handler(wsMux)
|
||||
|
||||
return siteHandler
|
||||
}
|
||||
|
||||
func (server *Server) setupHTTPServer(handler http.Handler) (*http.Server, error) {
|
||||
srv := &http.Server{
|
||||
Handler: handler,
|
||||
}
|
||||
|
||||
if server.options.EnableTLSClientAuth {
|
||||
tlsConfig, err := server.tlsConfig()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to setup TLS configuration")
|
||||
}
|
||||
srv.TLSConfig = tlsConfig
|
||||
}
|
||||
|
||||
return srv, nil
|
||||
}
|
||||
|
||||
func (server *Server) tlsConfig() (*tls.Config, error) {
|
||||
caFile := homedir.Expand(server.options.TLSCACrtFile)
|
||||
caCert, err := os.ReadFile(caFile)
|
||||
if err != nil {
|
||||
return nil, errors.New("could not open CA crt file " + caFile)
|
||||
}
|
||||
caCertPool := x509.NewCertPool()
|
||||
if !caCertPool.AppendCertsFromPEM(caCert) {
|
||||
return nil, errors.New("could not parse CA crt file data in " + caFile)
|
||||
}
|
||||
tlsConfig := &tls.Config{
|
||||
ClientCAs: caCertPool,
|
||||
ClientAuth: tls.RequireAndVerifyClientCert,
|
||||
}
|
||||
return tlsConfig, nil
|
||||
}
|
17
server/slave.go
Normal file
@ -0,0 +1,17 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/sorenisanerd/gotty/webtty"
|
||||
)
|
||||
|
||||
// Slave is webtty.Slave with some additional methods.
|
||||
type Slave interface {
|
||||
webtty.Slave
|
||||
|
||||
Close() error
|
||||
}
|
||||
|
||||
type Factory interface {
|
||||
Name() string
|
||||
New(params map[string][]string, headers map[string][]string) (Slave, error)
|
||||
}
|
41
server/ws_wrapper.go
Normal file
@ -0,0 +1,41 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type wsWrapper struct {
|
||||
*websocket.Conn
|
||||
}
|
||||
|
||||
func (wsw *wsWrapper) Write(p []byte) (n int, err error) {
|
||||
writer, err := wsw.Conn.NextWriter(websocket.TextMessage)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer writer.Close()
|
||||
return writer.Write(p)
|
||||
}
|
||||
|
||||
func (wsw *wsWrapper) Read(p []byte) (n int, err error) {
|
||||
for {
|
||||
msgType, reader, err := wsw.Conn.NextReader()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if msgType != websocket.TextMessage {
|
||||
continue
|
||||
}
|
||||
|
||||
b, err := io.ReadAll(reader)
|
||||
if len(b) > len(p) {
|
||||
return 0, errors.Wrapf(err, "Client message exceeded buffer size")
|
||||
}
|
||||
n = copy(p, b)
|
||||
return n, err
|
||||
}
|
||||
}
|
41
utils/default.go
Normal file
@ -0,0 +1,41 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fatih/structs"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func ApplyDefaultValues(struct_ interface{}) (err error) {
|
||||
o := structs.New(struct_)
|
||||
|
||||
for _, field := range o.Fields() {
|
||||
defaultValue := field.Tag("default")
|
||||
if defaultValue == "" {
|
||||
continue
|
||||
}
|
||||
var val interface{}
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
val = defaultValue
|
||||
case reflect.Bool:
|
||||
if defaultValue == "true" {
|
||||
val = true
|
||||
} else if defaultValue == "false" {
|
||||
val = false
|
||||
} else {
|
||||
return fmt.Errorf("invalid bool expression: %v, use true/false", defaultValue)
|
||||
}
|
||||
case reflect.Int:
|
||||
val, err = strconv.Atoi(defaultValue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
val = field.Value()
|
||||
}
|
||||
field.Set(val)
|
||||
}
|
||||
return nil
|
||||
}
|
128
utils/flags.go
Normal file
@ -0,0 +1,128 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/yudai/hcl"
|
||||
|
||||
"github.com/sorenisanerd/gotty/pkg/homedir"
|
||||
)
|
||||
|
||||
func GenerateFlags(options ...interface{}) (flags []cli.Flag, mappings map[string]string, err error) {
|
||||
mappings = make(map[string]string)
|
||||
|
||||
for _, struct_ := range options {
|
||||
o := structs.New(struct_)
|
||||
for _, field := range o.Fields() {
|
||||
flagName := field.Tag("flagName")
|
||||
if flagName == "" {
|
||||
continue
|
||||
}
|
||||
envName := "GOTTY_" + strings.ToUpper(strings.Join(strings.Split(flagName, "-"), "_"))
|
||||
mappings[flagName] = field.Name()
|
||||
|
||||
flagShortName := field.Tag("flagSName")
|
||||
var aliases []string
|
||||
if flagShortName != "" {
|
||||
aliases = []string{flagShortName}
|
||||
}
|
||||
|
||||
flagDescription := field.Tag("flagDescribe")
|
||||
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
flags = append(flags, &cli.StringFlag{
|
||||
Name: flagName,
|
||||
Value: field.Value().(string),
|
||||
Usage: flagDescription,
|
||||
EnvVars: []string{envName},
|
||||
Aliases: aliases,
|
||||
})
|
||||
case reflect.Bool:
|
||||
flags = append(flags, &cli.BoolFlag{
|
||||
Name: flagName,
|
||||
Usage: flagDescription,
|
||||
EnvVars: []string{envName},
|
||||
Aliases: aliases,
|
||||
DefaultText: field.Tag("default"),
|
||||
})
|
||||
case reflect.Int:
|
||||
flags = append(flags, &cli.IntFlag{
|
||||
Name: flagName,
|
||||
Value: field.Value().(int),
|
||||
Usage: flagDescription,
|
||||
EnvVars: []string{envName},
|
||||
Aliases: aliases,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ApplyFlags(
|
||||
flags []cli.Flag,
|
||||
mappingHint map[string]string,
|
||||
c *cli.Context,
|
||||
options ...interface{},
|
||||
) {
|
||||
objects := make([]*structs.Struct, len(options))
|
||||
for i, struct_ := range options {
|
||||
objects[i] = structs.New(struct_)
|
||||
}
|
||||
|
||||
for flagName, fieldName := range mappingHint {
|
||||
if !c.IsSet(flagName) {
|
||||
continue
|
||||
}
|
||||
var field *structs.Field
|
||||
var ok bool
|
||||
for _, o := range objects {
|
||||
field, ok = o.FieldOk(fieldName)
|
||||
if ok {
|
||||
break
|
||||
}
|
||||
}
|
||||
if field == nil {
|
||||
continue
|
||||
}
|
||||
var val interface{}
|
||||
switch field.Kind() {
|
||||
case reflect.String:
|
||||
val = c.String(flagName)
|
||||
case reflect.Bool:
|
||||
val = c.Bool(flagName)
|
||||
case reflect.Int:
|
||||
val = c.Int(flagName)
|
||||
}
|
||||
field.Set(val)
|
||||
}
|
||||
}
|
||||
|
||||
func ApplyConfigFile(filePath string, options ...interface{}) error {
|
||||
filePath = homedir.Expand(filePath)
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
fileString := []byte{}
|
||||
log.Printf("Loading config file at: %s", filePath)
|
||||
fileString, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, object := range options {
|
||||
if err := hcl.Decode(object, string(fileString)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
19
vendor/github.com/braintree/manners/LICENSE
generated
vendored
@ -1,19 +0,0 @@
|
||||
Copyright (c) 2014 Braintree, a division of PayPal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
36
vendor/github.com/braintree/manners/README.md
generated
vendored
@ -1,36 +0,0 @@
|
||||
# Manners
|
||||
|
||||
A *polite* webserver for Go.
|
||||
|
||||
Manners allows you to shut your Go webserver down gracefully, without dropping any requests. It can act as a drop-in replacement for the standard library's http.ListenAndServe function:
|
||||
|
||||
```go
|
||||
func main() {
|
||||
handler := MyHTTPHandler()
|
||||
manners.ListenAndServe(":7000", handler)
|
||||
}
|
||||
```
|
||||
|
||||
Then, when you want to shut the server down:
|
||||
|
||||
```go
|
||||
manners.Close()
|
||||
```
|
||||
|
||||
(Note that this does not block until all the requests are finished. Rather, the call to manners.ListenAndServe will stop blocking when all the requests are finished.)
|
||||
|
||||
Manners ensures that all requests are served by incrementing a WaitGroup when a request comes in and decrementing it when the request finishes.
|
||||
|
||||
If your request handler spawns Goroutines that are not guaranteed to finish with the request, you can ensure they are also completed with the `StartRoutine` and `FinishRoutine` functions on the server.
|
||||
|
||||
### Known Issues
|
||||
|
||||
Manners does not correctly shut down long-lived keepalive connections when issued a shutdown command. Clients on an idle keepalive connection may see a connection reset error rather than a close. See https://github.com/braintree/manners/issues/13 for details.
|
||||
|
||||
### Compatability
|
||||
|
||||
Manners 0.3.0 and above uses standard library functionality introduced in Go 1.3.
|
||||
|
||||
### Installation
|
||||
|
||||
`go get github.com/braintree/manners`
|
7
vendor/github.com/braintree/manners/interfaces.go
generated
vendored
@ -1,7 +0,0 @@
|
||||
package manners
|
||||
|
||||
type waitGroup interface {
|
||||
Add(int)
|
||||
Done()
|
||||
Wait()
|
||||
}
|
228
vendor/github.com/braintree/manners/server.go
generated
vendored
@ -1,228 +0,0 @@
|
||||
/*
|
||||
Package manners provides a wrapper for a standard net/http server that
|
||||
ensures all active HTTP client have completed their current request
|
||||
before the server shuts down.
|
||||
|
||||
It can be used a drop-in replacement for the standard http package,
|
||||
or can wrap a pre-configured Server.
|
||||
|
||||
eg.
|
||||
|
||||
http.Handle("/hello", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("Hello\n"))
|
||||
})
|
||||
|
||||
log.Fatal(manners.ListenAndServe(":8080", nil))
|
||||
|
||||
or for a customized server:
|
||||
|
||||
s := manners.NewWithServer(&http.Server{
|
||||
Addr: ":8080",
|
||||
Handler: myHandler,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
MaxHeaderBytes: 1 << 20,
|
||||
})
|
||||
log.Fatal(s.ListenAndServe())
|
||||
|
||||
The server will shut down cleanly when the Close() method is called:
|
||||
|
||||
go func() {
|
||||
sigchan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigchan, os.Interrupt, os.Kill)
|
||||
<-sigchan
|
||||
log.Info("Shutting down...")
|
||||
manners.Close()
|
||||
}()
|
||||
|
||||
http.Handle("/hello", myHandler)
|
||||
log.Fatal(manners.ListenAndServe(":8080", nil))
|
||||
*/
|
||||
package manners
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"net/http"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
// A GracefulServer maintains a WaitGroup that counts how many in-flight
|
||||
// requests the server is handling. When it receives a shutdown signal,
|
||||
// it stops accepting new requests but does not actually shut down until
|
||||
// all in-flight requests terminate.
|
||||
//
|
||||
// GracefulServer embeds the underlying net/http.Server making its non-override
|
||||
// methods and properties avaiable.
|
||||
//
|
||||
// It must be initialized by calling NewWithServer.
|
||||
type GracefulServer struct {
|
||||
*http.Server
|
||||
|
||||
shutdown chan bool
|
||||
wg waitGroup
|
||||
|
||||
lcsmu sync.RWMutex
|
||||
lastConnState map[net.Conn]http.ConnState
|
||||
|
||||
up chan net.Listener // Only used by test code.
|
||||
}
|
||||
|
||||
// NewWithServer wraps an existing http.Server object and returns a
|
||||
// GracefulServer that supports all of the original Server operations.
|
||||
func NewWithServer(s *http.Server) *GracefulServer {
|
||||
return &GracefulServer{
|
||||
Server: s,
|
||||
shutdown: make(chan bool),
|
||||
wg: new(sync.WaitGroup),
|
||||
lastConnState: make(map[net.Conn]http.ConnState),
|
||||
}
|
||||
}
|
||||
|
||||
// Close stops the server from accepting new requets and begins shutting down.
|
||||
// It returns true if it's the first time Close is called.
|
||||
func (s *GracefulServer) Close() bool {
|
||||
return <-s.shutdown
|
||||
}
|
||||
|
||||
// ListenAndServe provides a graceful equivalent of net/http.Serve.ListenAndServe.
|
||||
func (s *GracefulServer) ListenAndServe() error {
|
||||
addr := s.Addr
|
||||
if addr == "" {
|
||||
addr = ":http"
|
||||
}
|
||||
listener, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Serve(listener)
|
||||
}
|
||||
|
||||
// ListenAndServeTLS provides a graceful equivalent of net/http.Serve.ListenAndServeTLS.
|
||||
func (s *GracefulServer) ListenAndServeTLS(certFile, keyFile string) error {
|
||||
// direct lift from net/http/server.go
|
||||
addr := s.Addr
|
||||
if addr == "" {
|
||||
addr = ":https"
|
||||
}
|
||||
config := &tls.Config{}
|
||||
if s.TLSConfig != nil {
|
||||
*config = *s.TLSConfig
|
||||
}
|
||||
if config.NextProtos == nil {
|
||||
config.NextProtos = []string{"http/1.1"}
|
||||
}
|
||||
|
||||
var err error
|
||||
config.Certificates = make([]tls.Certificate, 1)
|
||||
config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.Serve(tls.NewListener(ln, config))
|
||||
}
|
||||
|
||||
// Serve provides a graceful equivalent net/http.Server.Serve.
|
||||
func (s *GracefulServer) Serve(listener net.Listener) error {
|
||||
var closing int32
|
||||
|
||||
go func() {
|
||||
s.shutdown <- true
|
||||
close(s.shutdown)
|
||||
atomic.StoreInt32(&closing, 1)
|
||||
s.Server.SetKeepAlivesEnabled(false)
|
||||
listener.Close()
|
||||
}()
|
||||
|
||||
originalConnState := s.Server.ConnState
|
||||
|
||||
// s.ConnState is invoked by the net/http.Server every time a connectiion
|
||||
// changes state. It keeps track of each connection's state over time,
|
||||
// enabling manners to handle persisted connections correctly.
|
||||
s.ConnState = func(conn net.Conn, newState http.ConnState) {
|
||||
s.lcsmu.RLock()
|
||||
lastConnState := s.lastConnState[conn]
|
||||
s.lcsmu.RUnlock()
|
||||
|
||||
switch newState {
|
||||
|
||||
// New connection -> StateNew
|
||||
case http.StateNew:
|
||||
s.StartRoutine()
|
||||
|
||||
// (StateNew, StateIdle) -> StateActive
|
||||
case http.StateActive:
|
||||
// The connection transitioned from idle back to active
|
||||
if lastConnState == http.StateIdle {
|
||||
s.StartRoutine()
|
||||
}
|
||||
|
||||
// StateActive -> StateIdle
|
||||
// Immediately close newly idle connections; if not they may make
|
||||
// one more request before SetKeepAliveEnabled(false) takes effect.
|
||||
case http.StateIdle:
|
||||
if atomic.LoadInt32(&closing) == 1 {
|
||||
conn.Close()
|
||||
}
|
||||
s.FinishRoutine()
|
||||
|
||||
// (StateNew, StateActive, StateIdle) -> (StateClosed, StateHiJacked)
|
||||
// If the connection was idle we do not need to decrement the counter.
|
||||
case http.StateClosed, http.StateHijacked:
|
||||
if lastConnState != http.StateIdle {
|
||||
s.FinishRoutine()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
s.lcsmu.Lock()
|
||||
if newState == http.StateClosed || newState == http.StateHijacked {
|
||||
delete(s.lastConnState, conn)
|
||||
} else {
|
||||
s.lastConnState[conn] = newState
|
||||
}
|
||||
s.lcsmu.Unlock()
|
||||
|
||||
if originalConnState != nil {
|
||||
originalConnState(conn, newState)
|
||||
}
|
||||
}
|
||||
|
||||
// A hook to allow the server to notify others when it is ready to receive
|
||||
// requests; only used by tests.
|
||||
if s.up != nil {
|
||||
s.up <- listener
|
||||
}
|
||||
|
||||
err := s.Server.Serve(listener)
|
||||
|
||||
// This block is reached when the server has received a shut down command
|
||||
// or a real error happened.
|
||||
if err == nil || atomic.LoadInt32(&closing) == 1 {
|
||||
s.wg.Wait()
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// StartRoutine increments the server's WaitGroup. Use this if a web request
|
||||
// starts more goroutines and these goroutines are not guaranteed to finish
|
||||
// before the request.
|
||||
func (s *GracefulServer) StartRoutine() {
|
||||
s.wg.Add(1)
|
||||
}
|
||||
|
||||
// FinishRoutine decrements the server's WaitGroup. Use this to complement
|
||||
// StartRoutine().
|
||||
func (s *GracefulServer) FinishRoutine() {
|
||||
s.wg.Done()
|
||||
}
|
35
vendor/github.com/braintree/manners/static.go
generated
vendored
@ -1,35 +0,0 @@
|
||||
package manners
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var defaultServer *GracefulServer
|
||||
|
||||
// ListenAndServe provides a graceful version of the function provided by the
|
||||
// net/http package. Call Close() to stop the server.
|
||||
func ListenAndServe(addr string, handler http.Handler) error {
|
||||
defaultServer = NewWithServer(&http.Server{Addr: addr, Handler: handler})
|
||||
return defaultServer.ListenAndServe()
|
||||
}
|
||||
|
||||
// ListenAndServeTLS provides a graceful version of the function provided by the
|
||||
// net/http package. Call Close() to stop the server.
|
||||
func ListenAndServeTLS(addr string, certFile string, keyFile string, handler http.Handler) error {
|
||||
defaultServer = NewWithServer(&http.Server{Addr: addr, Handler: handler})
|
||||
return defaultServer.ListenAndServeTLS(certFile, keyFile)
|
||||
}
|
||||
|
||||
// Serve provides a graceful version of the function provided by the net/http
|
||||
// package. Call Close() to stop the server.
|
||||
func Serve(l net.Listener, handler http.Handler) error {
|
||||
defaultServer = NewWithServer(&http.Server{Handler: handler})
|
||||
return defaultServer.Serve(l)
|
||||
}
|
||||
|
||||
// Shuts down the default server used by ListenAndServe, ListenAndServeTLS and
|
||||
// Serve. It returns true if it's the first time Close is called.
|
||||
func Close() bool {
|
||||
return defaultServer.Close()
|
||||
}
|
13
vendor/github.com/codegangsta/cli/.travis.yml
generated
vendored
@ -1,13 +0,0 @@
|
||||
language: go
|
||||
sudo: false
|
||||
|
||||
go:
|
||||
- 1.0.3
|
||||
- 1.1.2
|
||||
- 1.2.2
|
||||
- 1.3.3
|
||||
- 1.4.2
|
||||
|
||||
script:
|
||||
- go vet ./...
|
||||
- go test -v ./...
|
21
vendor/github.com/codegangsta/cli/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
||||
Copyright (C) 2013 Jeremy Saenz
|
||||
All Rights Reserved.
|
||||
|
||||
MIT LICENSE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
308
vendor/github.com/codegangsta/cli/README.md
generated
vendored
@ -1,308 +0,0 @@
|
||||
[](https://travis-ci.org/codegangsta/cli)
|
||||
|
||||
# cli.go
|
||||
cli.go is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.
|
||||
|
||||
You can view the API docs here:
|
||||
http://godoc.org/github.com/codegangsta/cli
|
||||
|
||||
## Overview
|
||||
Command line apps are usually so tiny that there is absolutely no reason why your code should *not* be self-documenting. Things like generating help text and parsing command flags/options should not hinder productivity when writing a command line app.
|
||||
|
||||
**This is where cli.go comes into play.** cli.go makes command line programming fun, organized, and expressive!
|
||||
|
||||
## Installation
|
||||
Make sure you have a working Go environment (go 1.1+ is *required*). [See the install instructions](http://golang.org/doc/install.html).
|
||||
|
||||
To install `cli.go`, simply run:
|
||||
```
|
||||
$ go get github.com/codegangsta/cli
|
||||
```
|
||||
|
||||
Make sure your `PATH` includes to the `$GOPATH/bin` directory so your commands can be easily used:
|
||||
```
|
||||
export PATH=$PATH:$GOPATH/bin
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
One of the philosophies behind cli.go is that an API should be playful and full of discovery. So a cli.go app can be as little as one line of code in `main()`.
|
||||
|
||||
``` go
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"github.com/codegangsta/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cli.NewApp().Run(os.Args)
|
||||
}
|
||||
```
|
||||
|
||||
This app will run and show help text, but is not very useful. Let's give an action to execute and some help documentation:
|
||||
|
||||
``` go
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"github.com/codegangsta/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "boom"
|
||||
app.Usage = "make an explosive entrance"
|
||||
app.Action = func(c *cli.Context) {
|
||||
println("boom! I say!")
|
||||
}
|
||||
|
||||
app.Run(os.Args)
|
||||
}
|
||||
```
|
||||
|
||||
Running this already gives you a ton of functionality, plus support for things like subcommands and flags, which are covered below.
|
||||
|
||||
## Example
|
||||
|
||||
Being a programmer can be a lonely job. Thankfully by the power of automation that is not the case! Let's create a greeter app to fend off our demons of loneliness!
|
||||
|
||||
Start by creating a directory named `greet`, and within it, add a file, `greet.go` with the following code in it:
|
||||
|
||||
``` go
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"github.com/codegangsta/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "greet"
|
||||
app.Usage = "fight the loneliness!"
|
||||
app.Action = func(c *cli.Context) {
|
||||
println("Hello friend!")
|
||||
}
|
||||
|
||||
app.Run(os.Args)
|
||||
}
|
||||
```
|
||||
|
||||
Install our command to the `$GOPATH/bin` directory:
|
||||
|
||||
```
|
||||
$ go install
|
||||
```
|
||||
|
||||
Finally run our new command:
|
||||
|
||||
```
|
||||
$ greet
|
||||
Hello friend!
|
||||
```
|
||||
|
||||
cli.go also generates some bitchass help text:
|
||||
```
|
||||
$ greet help
|
||||
NAME:
|
||||
greet - fight the loneliness!
|
||||
|
||||
USAGE:
|
||||
greet [global options] command [command options] [arguments...]
|
||||
|
||||
VERSION:
|
||||
0.0.0
|
||||
|
||||
COMMANDS:
|
||||
help, h Shows a list of commands or help for one command
|
||||
|
||||
GLOBAL OPTIONS
|
||||
--version Shows version information
|
||||
```
|
||||
|
||||
### Arguments
|
||||
You can lookup arguments by calling the `Args` function on `cli.Context`.
|
||||
|
||||
``` go
|
||||
...
|
||||
app.Action = func(c *cli.Context) {
|
||||
println("Hello", c.Args()[0])
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
### Flags
|
||||
Setting and querying flags is simple.
|
||||
``` go
|
||||
...
|
||||
app.Flags = []cli.Flag {
|
||||
cli.StringFlag{
|
||||
Name: "lang",
|
||||
Value: "english",
|
||||
Usage: "language for the greeting",
|
||||
},
|
||||
}
|
||||
app.Action = func(c *cli.Context) {
|
||||
name := "someone"
|
||||
if len(c.Args()) > 0 {
|
||||
name = c.Args()[0]
|
||||
}
|
||||
if c.String("lang") == "spanish" {
|
||||
println("Hola", name)
|
||||
} else {
|
||||
println("Hello", name)
|
||||
}
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
See full list of flags at http://godoc.org/github.com/codegangsta/cli
|
||||
|
||||
#### Alternate Names
|
||||
|
||||
You can set alternate (or short) names for flags by providing a comma-delimited list for the `Name`. e.g.
|
||||
|
||||
``` go
|
||||
app.Flags = []cli.Flag {
|
||||
cli.StringFlag{
|
||||
Name: "lang, l",
|
||||
Value: "english",
|
||||
Usage: "language for the greeting",
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
That flag can then be set with `--lang spanish` or `-l spanish`. Note that giving two different forms of the same flag in the same command invocation is an error.
|
||||
|
||||
#### Values from the Environment
|
||||
|
||||
You can also have the default value set from the environment via `EnvVar`. e.g.
|
||||
|
||||
``` go
|
||||
app.Flags = []cli.Flag {
|
||||
cli.StringFlag{
|
||||
Name: "lang, l",
|
||||
Value: "english",
|
||||
Usage: "language for the greeting",
|
||||
EnvVar: "APP_LANG",
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
The `EnvVar` may also be given as a comma-delimited "cascade", where the first environment variable that resolves is used as the default.
|
||||
|
||||
``` go
|
||||
app.Flags = []cli.Flag {
|
||||
cli.StringFlag{
|
||||
Name: "lang, l",
|
||||
Value: "english",
|
||||
Usage: "language for the greeting",
|
||||
EnvVar: "LEGACY_COMPAT_LANG,APP_LANG,LANG",
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### Subcommands
|
||||
|
||||
Subcommands can be defined for a more git-like command line app.
|
||||
```go
|
||||
...
|
||||
app.Commands = []cli.Command{
|
||||
{
|
||||
Name: "add",
|
||||
Aliases: []string{"a"},
|
||||
Usage: "add a task to the list",
|
||||
Action: func(c *cli.Context) {
|
||||
println("added task: ", c.Args().First())
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "complete",
|
||||
Aliases: []string{"c"},
|
||||
Usage: "complete a task on the list",
|
||||
Action: func(c *cli.Context) {
|
||||
println("completed task: ", c.Args().First())
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "template",
|
||||
Aliases: []string{"r"},
|
||||
Usage: "options for task templates",
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
Name: "add",
|
||||
Usage: "add a new template",
|
||||
Action: func(c *cli.Context) {
|
||||
println("new task template: ", c.Args().First())
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "remove",
|
||||
Usage: "remove an existing template",
|
||||
Action: func(c *cli.Context) {
|
||||
println("removed task template: ", c.Args().First())
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
### Bash Completion
|
||||
|
||||
You can enable completion commands by setting the `EnableBashCompletion`
|
||||
flag on the `App` object. By default, this setting will only auto-complete to
|
||||
show an app's subcommands, but you can write your own completion methods for
|
||||
the App or its subcommands.
|
||||
```go
|
||||
...
|
||||
var tasks = []string{"cook", "clean", "laundry", "eat", "sleep", "code"}
|
||||
app := cli.NewApp()
|
||||
app.EnableBashCompletion = true
|
||||
app.Commands = []cli.Command{
|
||||
{
|
||||
Name: "complete",
|
||||
Aliases: []string{"c"},
|
||||
Usage: "complete a task on the list",
|
||||
Action: func(c *cli.Context) {
|
||||
println("completed task: ", c.Args().First())
|
||||
},
|
||||
BashComplete: func(c *cli.Context) {
|
||||
// This will complete if no args are passed
|
||||
if len(c.Args()) > 0 {
|
||||
return
|
||||
}
|
||||
for _, t := range tasks {
|
||||
fmt.Println(t)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
#### To Enable
|
||||
|
||||
Source the `autocomplete/bash_autocomplete` file in your `.bashrc` file while
|
||||
setting the `PROG` variable to the name of your program:
|
||||
|
||||
`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete`
|
||||
|
||||
#### To Distribute
|
||||
|
||||
Copy and modify `autocomplete/bash_autocomplete` to use your program name
|
||||
rather than `$PROG` and have the user copy the file into
|
||||
`/etc/bash_completion.d/` (or automatically install it there if you are
|
||||
distributing a package). Alternatively you can just document that users should
|
||||
source the generic `autocomplete/bash_autocomplete` with `$PROG` set to your
|
||||
program name in their bash configuration.
|
||||
|
||||
## Contribution Guidelines
|
||||
Feel free to put up a pull request to fix a bug or maybe add a feature. I will give it a code review and make sure that it does not break backwards compatibility. If I or any other collaborators agree that it is in line with the vision of the project, we will work with you to get the code into a mergeable state and merge it into the master branch.
|
||||
|
||||
If you have contributed something significant to the project, I will most likely add you as a collaborator. As a collaborator you are given the ability to merge others pull requests. It is very important that new code does not break existing code, so be careful about what code you do choose to merge. If you have any questions feel free to link @codegangsta to the issue in question and we can review it together.
|
||||
|
||||
If you feel like you have contributed to the project but have not yet been added as a collaborator, I probably forgot to add you. Hit @codegangsta up over email and we will get it figured out.
|
308
vendor/github.com/codegangsta/cli/app.go
generated
vendored
@ -1,308 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// App is the main structure of a cli application. It is recomended that
|
||||
// an app be created with the cli.NewApp() function
|
||||
type App struct {
|
||||
// The name of the program. Defaults to os.Args[0]
|
||||
Name string
|
||||
// Description of the program.
|
||||
Usage string
|
||||
// Version of the program
|
||||
Version string
|
||||
// List of commands to execute
|
||||
Commands []Command
|
||||
// List of flags to parse
|
||||
Flags []Flag
|
||||
// Boolean to enable bash completion commands
|
||||
EnableBashCompletion bool
|
||||
// Boolean to hide built-in help command
|
||||
HideHelp bool
|
||||
// Boolean to hide built-in version flag
|
||||
HideVersion bool
|
||||
// An action to execute when the bash-completion flag is set
|
||||
BashComplete func(context *Context)
|
||||
// An action to execute before any subcommands are run, but after the context is ready
|
||||
// If a non-nil error is returned, no subcommands are run
|
||||
Before func(context *Context) error
|
||||
// An action to execute after any subcommands are run, but after the subcommand has finished
|
||||
// It is run even if Action() panics
|
||||
After func(context *Context) error
|
||||
// The action to execute when no subcommands are specified
|
||||
Action func(context *Context)
|
||||
// Execute this function if the proper command cannot be found
|
||||
CommandNotFound func(context *Context, command string)
|
||||
// Compilation date
|
||||
Compiled time.Time
|
||||
// List of all authors who contributed
|
||||
Authors []Author
|
||||
// Copyright of the binary if any
|
||||
Copyright string
|
||||
// Name of Author (Note: Use App.Authors, this is deprecated)
|
||||
Author string
|
||||
// Email of Author (Note: Use App.Authors, this is deprecated)
|
||||
Email string
|
||||
// Writer writer to write output to
|
||||
Writer io.Writer
|
||||
}
|
||||
|
||||
// Tries to find out when this binary was compiled.
|
||||
// Returns the current time if it fails to find it.
|
||||
func compileTime() time.Time {
|
||||
info, err := os.Stat(os.Args[0])
|
||||
if err != nil {
|
||||
return time.Now()
|
||||
}
|
||||
return info.ModTime()
|
||||
}
|
||||
|
||||
// Creates a new cli Application with some reasonable defaults for Name, Usage, Version and Action.
|
||||
func NewApp() *App {
|
||||
return &App{
|
||||
Name: os.Args[0],
|
||||
Usage: "A new cli application",
|
||||
Version: "0.0.0",
|
||||
BashComplete: DefaultAppComplete,
|
||||
Action: helpCommand.Action,
|
||||
Compiled: compileTime(),
|
||||
Writer: os.Stdout,
|
||||
}
|
||||
}
|
||||
|
||||
// Entry point to the cli app. Parses the arguments slice and routes to the proper flag/args combination
|
||||
func (a *App) Run(arguments []string) (err error) {
|
||||
if a.Author != "" || a.Email != "" {
|
||||
a.Authors = append(a.Authors, Author{Name: a.Author, Email: a.Email})
|
||||
}
|
||||
|
||||
// append help to commands
|
||||
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
|
||||
a.Commands = append(a.Commands, helpCommand)
|
||||
if (HelpFlag != BoolFlag{}) {
|
||||
a.appendFlag(HelpFlag)
|
||||
}
|
||||
}
|
||||
|
||||
//append version/help flags
|
||||
if a.EnableBashCompletion {
|
||||
a.appendFlag(BashCompletionFlag)
|
||||
}
|
||||
|
||||
if !a.HideVersion {
|
||||
a.appendFlag(VersionFlag)
|
||||
}
|
||||
|
||||
// parse flags
|
||||
set := flagSet(a.Name, a.Flags)
|
||||
set.SetOutput(ioutil.Discard)
|
||||
err = set.Parse(arguments[1:])
|
||||
nerr := normalizeFlags(a.Flags, set)
|
||||
if nerr != nil {
|
||||
fmt.Fprintln(a.Writer, nerr)
|
||||
context := NewContext(a, set, nil)
|
||||
ShowAppHelp(context)
|
||||
return nerr
|
||||
}
|
||||
context := NewContext(a, set, nil)
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintln(a.Writer, "Incorrect Usage.")
|
||||
fmt.Fprintln(a.Writer)
|
||||
ShowAppHelp(context)
|
||||
return err
|
||||
}
|
||||
|
||||
if checkCompletions(context) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if checkHelp(context) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if checkVersion(context) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if a.After != nil {
|
||||
defer func() {
|
||||
afterErr := a.After(context)
|
||||
if afterErr != nil {
|
||||
if err != nil {
|
||||
err = NewMultiError(err, afterErr)
|
||||
} else {
|
||||
err = afterErr
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if a.Before != nil {
|
||||
err := a.Before(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
args := context.Args()
|
||||
if args.Present() {
|
||||
name := args.First()
|
||||
c := a.Command(name)
|
||||
if c != nil {
|
||||
return c.Run(context)
|
||||
}
|
||||
}
|
||||
|
||||
// Run default Action
|
||||
a.Action(context)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Another entry point to the cli app, takes care of passing arguments and error handling
|
||||
func (a *App) RunAndExitOnError() {
|
||||
if err := a.Run(os.Args); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Invokes the subcommand given the context, parses ctx.Args() to generate command-specific flags
|
||||
func (a *App) RunAsSubcommand(ctx *Context) (err error) {
|
||||
// append help to commands
|
||||
if len(a.Commands) > 0 {
|
||||
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
|
||||
a.Commands = append(a.Commands, helpCommand)
|
||||
if (HelpFlag != BoolFlag{}) {
|
||||
a.appendFlag(HelpFlag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// append flags
|
||||
if a.EnableBashCompletion {
|
||||
a.appendFlag(BashCompletionFlag)
|
||||
}
|
||||
|
||||
// parse flags
|
||||
set := flagSet(a.Name, a.Flags)
|
||||
set.SetOutput(ioutil.Discard)
|
||||
err = set.Parse(ctx.Args().Tail())
|
||||
nerr := normalizeFlags(a.Flags, set)
|
||||
context := NewContext(a, set, ctx)
|
||||
|
||||
if nerr != nil {
|
||||
fmt.Fprintln(a.Writer, nerr)
|
||||
fmt.Fprintln(a.Writer)
|
||||
if len(a.Commands) > 0 {
|
||||
ShowSubcommandHelp(context)
|
||||
} else {
|
||||
ShowCommandHelp(ctx, context.Args().First())
|
||||
}
|
||||
return nerr
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintln(a.Writer, "Incorrect Usage.")
|
||||
fmt.Fprintln(a.Writer)
|
||||
ShowSubcommandHelp(context)
|
||||
return err
|
||||
}
|
||||
|
||||
if checkCompletions(context) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(a.Commands) > 0 {
|
||||
if checkSubcommandHelp(context) {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
if checkCommandHelp(ctx, context.Args().First()) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
if a.After != nil {
|
||||
defer func() {
|
||||
afterErr := a.After(context)
|
||||
if afterErr != nil {
|
||||
if err != nil {
|
||||
err = NewMultiError(err, afterErr)
|
||||
} else {
|
||||
err = afterErr
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if a.Before != nil {
|
||||
err := a.Before(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
args := context.Args()
|
||||
if args.Present() {
|
||||
name := args.First()
|
||||
c := a.Command(name)
|
||||
if c != nil {
|
||||
return c.Run(context)
|
||||
}
|
||||
}
|
||||
|
||||
// Run default Action
|
||||
a.Action(context)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Returns the named command on App. Returns nil if the command does not exist
|
||||
func (a *App) Command(name string) *Command {
|
||||
for _, c := range a.Commands {
|
||||
if c.HasName(name) {
|
||||
return &c
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) hasFlag(flag Flag) bool {
|
||||
for _, f := range a.Flags {
|
||||
if flag == f {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *App) appendFlag(flag Flag) {
|
||||
if !a.hasFlag(flag) {
|
||||
a.Flags = append(a.Flags, flag)
|
||||
}
|
||||
}
|
||||
|
||||
// Author represents someone who has contributed to a cli project.
|
||||
type Author struct {
|
||||
Name string // The Authors name
|
||||
Email string // The Authors email
|
||||
}
|
||||
|
||||
// String makes Author comply to the Stringer interface, to allow an easy print in the templating process
|
||||
func (a Author) String() string {
|
||||
e := ""
|
||||
if a.Email != "" {
|
||||
e = "<" + a.Email + "> "
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v %v", a.Name, e)
|
||||
}
|
40
vendor/github.com/codegangsta/cli/cli.go
generated
vendored
@ -1,40 +0,0 @@
|
||||
// Package cli provides a minimal framework for creating and organizing command line
|
||||
// Go applications. cli is designed to be easy to understand and write, the most simple
|
||||
// cli application can be written as follows:
|
||||
// func main() {
|
||||
// cli.NewApp().Run(os.Args)
|
||||
// }
|
||||
//
|
||||
// Of course this application does not do much, so let's make this an actual application:
|
||||
// func main() {
|
||||
// app := cli.NewApp()
|
||||
// app.Name = "greet"
|
||||
// app.Usage = "say a greeting"
|
||||
// app.Action = func(c *cli.Context) {
|
||||
// println("Greetings")
|
||||
// }
|
||||
//
|
||||
// app.Run(os.Args)
|
||||
// }
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type MultiError struct {
|
||||
Errors []error
|
||||
}
|
||||
|
||||
func NewMultiError(err ...error) MultiError {
|
||||
return MultiError{Errors: err}
|
||||
}
|
||||
|
||||
func (m MultiError) Error() string {
|
||||
errs := make([]string, len(m.Errors))
|
||||
for i, err := range m.Errors {
|
||||
errs[i] = err.Error()
|
||||
}
|
||||
|
||||
return strings.Join(errs, "\n")
|
||||
}
|
200
vendor/github.com/codegangsta/cli/command.go
generated
vendored
@ -1,200 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Command is a subcommand for a cli.App.
|
||||
type Command struct {
|
||||
// The name of the command
|
||||
Name string
|
||||
// short name of the command. Typically one character (deprecated, use `Aliases`)
|
||||
ShortName string
|
||||
// A list of aliases for the command
|
||||
Aliases []string
|
||||
// A short description of the usage of this command
|
||||
Usage string
|
||||
// A longer explanation of how the command works
|
||||
Description string
|
||||
// The function to call when checking for bash command completions
|
||||
BashComplete func(context *Context)
|
||||
// An action to execute before any sub-subcommands are run, but after the context is ready
|
||||
// If a non-nil error is returned, no sub-subcommands are run
|
||||
Before func(context *Context) error
|
||||
// An action to execute after any subcommands are run, but after the subcommand has finished
|
||||
// It is run even if Action() panics
|
||||
After func(context *Context) error
|
||||
// The function to call when this command is invoked
|
||||
Action func(context *Context)
|
||||
// List of child commands
|
||||
Subcommands []Command
|
||||
// List of flags to parse
|
||||
Flags []Flag
|
||||
// Treat all flags as normal arguments if true
|
||||
SkipFlagParsing bool
|
||||
// Boolean to hide built-in help command
|
||||
HideHelp bool
|
||||
|
||||
commandNamePath []string
|
||||
}
|
||||
|
||||
// Returns the full name of the command.
|
||||
// For subcommands this ensures that parent commands are part of the command path
|
||||
func (c Command) FullName() string {
|
||||
if c.commandNamePath == nil {
|
||||
return c.Name
|
||||
}
|
||||
return strings.Join(c.commandNamePath, " ")
|
||||
}
|
||||
|
||||
// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
|
||||
func (c Command) Run(ctx *Context) error {
|
||||
if len(c.Subcommands) > 0 || c.Before != nil || c.After != nil {
|
||||
return c.startApp(ctx)
|
||||
}
|
||||
|
||||
if !c.HideHelp && (HelpFlag != BoolFlag{}) {
|
||||
// append help to flags
|
||||
c.Flags = append(
|
||||
c.Flags,
|
||||
HelpFlag,
|
||||
)
|
||||
}
|
||||
|
||||
if ctx.App.EnableBashCompletion {
|
||||
c.Flags = append(c.Flags, BashCompletionFlag)
|
||||
}
|
||||
|
||||
set := flagSet(c.Name, c.Flags)
|
||||
set.SetOutput(ioutil.Discard)
|
||||
|
||||
firstFlagIndex := -1
|
||||
terminatorIndex := -1
|
||||
for index, arg := range ctx.Args() {
|
||||
if arg == "--" {
|
||||
terminatorIndex = index
|
||||
break
|
||||
} else if strings.HasPrefix(arg, "-") && firstFlagIndex == -1 {
|
||||
firstFlagIndex = index
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
if firstFlagIndex > -1 && !c.SkipFlagParsing {
|
||||
args := ctx.Args()
|
||||
regularArgs := make([]string, len(args[1:firstFlagIndex]))
|
||||
copy(regularArgs, args[1:firstFlagIndex])
|
||||
|
||||
var flagArgs []string
|
||||
if terminatorIndex > -1 {
|
||||
flagArgs = args[firstFlagIndex:terminatorIndex]
|
||||
regularArgs = append(regularArgs, args[terminatorIndex:]...)
|
||||
} else {
|
||||
flagArgs = args[firstFlagIndex:]
|
||||
}
|
||||
|
||||
err = set.Parse(append(flagArgs, regularArgs...))
|
||||
} else {
|
||||
err = set.Parse(ctx.Args().Tail())
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintln(ctx.App.Writer, "Incorrect Usage.")
|
||||
fmt.Fprintln(ctx.App.Writer)
|
||||
ShowCommandHelp(ctx, c.Name)
|
||||
return err
|
||||
}
|
||||
|
||||
nerr := normalizeFlags(c.Flags, set)
|
||||
if nerr != nil {
|
||||
fmt.Fprintln(ctx.App.Writer, nerr)
|
||||
fmt.Fprintln(ctx.App.Writer)
|
||||
ShowCommandHelp(ctx, c.Name)
|
||||
return nerr
|
||||
}
|
||||
context := NewContext(ctx.App, set, ctx)
|
||||
|
||||
if checkCommandCompletions(context, c.Name) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if checkCommandHelp(context, c.Name) {
|
||||
return nil
|
||||
}
|
||||
context.Command = c
|
||||
c.Action(context)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c Command) Names() []string {
|
||||
names := []string{c.Name}
|
||||
|
||||
if c.ShortName != "" {
|
||||
names = append(names, c.ShortName)
|
||||
}
|
||||
|
||||
return append(names, c.Aliases...)
|
||||
}
|
||||
|
||||
// Returns true if Command.Name or Command.ShortName matches given name
|
||||
func (c Command) HasName(name string) bool {
|
||||
for _, n := range c.Names() {
|
||||
if n == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (c Command) startApp(ctx *Context) error {
|
||||
app := NewApp()
|
||||
|
||||
// set the name and usage
|
||||
app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
|
||||
if c.Description != "" {
|
||||
app.Usage = c.Description
|
||||
} else {
|
||||
app.Usage = c.Usage
|
||||
}
|
||||
|
||||
// set CommandNotFound
|
||||
app.CommandNotFound = ctx.App.CommandNotFound
|
||||
|
||||
// set the flags and commands
|
||||
app.Commands = c.Subcommands
|
||||
app.Flags = c.Flags
|
||||
app.HideHelp = c.HideHelp
|
||||
|
||||
app.Version = ctx.App.Version
|
||||
app.HideVersion = ctx.App.HideVersion
|
||||
app.Compiled = ctx.App.Compiled
|
||||
app.Author = ctx.App.Author
|
||||
app.Email = ctx.App.Email
|
||||
app.Writer = ctx.App.Writer
|
||||
|
||||
// bash completion
|
||||
app.EnableBashCompletion = ctx.App.EnableBashCompletion
|
||||
if c.BashComplete != nil {
|
||||
app.BashComplete = c.BashComplete
|
||||
}
|
||||
|
||||
// set the actions
|
||||
app.Before = c.Before
|
||||
app.After = c.After
|
||||
if c.Action != nil {
|
||||
app.Action = c.Action
|
||||
} else {
|
||||
app.Action = helpSubcommand.Action
|
||||
}
|
||||
|
||||
var newCmds []Command
|
||||
for _, cc := range app.Commands {
|
||||
cc.commandNamePath = []string{c.Name, cc.Name}
|
||||
newCmds = append(newCmds, cc)
|
||||
}
|
||||
app.Commands = newCmds
|
||||
|
||||
return app.RunAsSubcommand(ctx)
|
||||
}
|