Skip to content

Commit

Permalink
Merge pull request #1 from Labbs/init
Browse files Browse the repository at this point in the history
init project
  • Loading branch information
moutonjeremy authored Oct 17, 2023
2 parents b87f441 + 885a64c commit 482b242
Show file tree
Hide file tree
Showing 59 changed files with 5,704 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./tmp/main tmux new -A -s ttyd bash"
cmd = "go build -o ./tmp/main ."
delay = 0
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = true

[screen]
clear_on_rebuild = false
keep_scroll = true
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
43 changes: 43 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ci

on:
push:
tags:
- 'v*'

permissions:
contents: read
packages: write

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
# go-version: 1.19
go-version-file: go.mod
# The builtin cache feature ensures that installing golangci-lint
# is consistently fast.
cache: true
cache-dependency-path: go.sum

- uses: nowsprinting/check-version-format-action@v3
if: github.event_name != 'pull_request'
id: version
with:
prefix: 'v'

- name: Build app
run: CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -a -installsuffix cgo -ldflags="-X 'main.version=${{ steps.version.outputs.full }}'" -o bin/webtty .

- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: true
files: bin/webtty
prerelease: ${{ steps.version.outputs.is_stable }}
26 changes: 26 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: golangci-lint
on:
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
# go-version: 1.19
go-version-file: go.mod
# The builtin cache feature ensures that installing golangci-lint
# is consistently fast.
cache: true
cache-dependency-path: go.sum
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 3m
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

# Go workspace file
go.work

*.log
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# webtty
TTY over HTTP

This a fork of [Gotty](https://github.com/yudai/gotty). It is a tool for sharing terminal over the web.
It has been updated for some dependencies and also the addition of features.
- Session recording
- Word blacklisting

Work is still in progress for recording and word blacklisting
1 change: 1 addition & 0 deletions backend/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package backend
3 changes: 3 additions & 0 deletions backend/localcommand/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package localcommand provides an implementation of webtty.Slave
// that launches a local command with a PTY.
package localcommand
48 changes: 48 additions & 0 deletions backend/localcommand/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package localcommand

import (
"syscall"
"time"

"github.com/labbs/webtty/server"
)

type Options struct {
CloseSignal int
CloseTimeout int
}

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) (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, factory.opts...)
}
Loading

0 comments on commit 482b242

Please sign in to comment.