Skip to content

Commit 7d76d32

Browse files
committed
Merge branch 'main' into rmwebrtc
2 parents 3492088 + 9196b39 commit 7d76d32

File tree

256 files changed

+5652
-2133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+5652
-2133
lines changed

.devcontainer/Dockerfile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
FROM ubuntu
2+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3+
4+
ENV EDITOR=vim
5+
6+
RUN apt-get update && apt-get upgrade
7+
8+
RUN apt-get install --yes \
9+
ca-certificates \
10+
bash-completion \
11+
build-essential \
12+
curl \
13+
cmake \
14+
direnv \
15+
emacs-nox \
16+
gnupg \
17+
htop \
18+
jq \
19+
less \
20+
lsb-release \
21+
lsof \
22+
man-db \
23+
nano \
24+
neovim \
25+
ssl-cert \
26+
sudo \
27+
unzip \
28+
xz-utils \
29+
zip
30+
31+
# configure locales to UTF8
32+
RUN apt-get install locales && locale-gen en_US.UTF-8
33+
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
34+
35+
# configure direnv
36+
RUN direnv hook bash >> $HOME/.bashrc
37+
38+
# install nix
39+
RUN sh <(curl -L https://nixos.org/nix/install) --daemon
40+
41+
RUN mkdir -p $HOME/.config/nix $HOME/.config/nixpkgs \
42+
&& echo 'sandbox = false' >> $HOME/.config/nix/nix.conf \
43+
&& echo '{ allowUnfree = true; }' >> $HOME/.config/nixpkgs/config.nix \
44+
&& echo '. $HOME/.nix-profile/etc/profile.d/nix.sh' >> $HOME/.bashrc
45+
46+
47+
# install docker and configure daemon to use vfs as GitHub codespaces requires vfs
48+
# https://github.com/moby/moby/issues/13742#issuecomment-725197223
49+
RUN mkdir -p /etc/apt/keyrings \
50+
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
51+
&& echo \
52+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
53+
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null \
54+
&& apt-get update \
55+
&& apt-get install --yes docker-ce docker-ce-cli containerd.io docker-compose-plugin \
56+
&& mkdir -p /etc/docker \
57+
&& echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' >> /etc/docker/daemon.json
58+
59+
# install golang and language tooling
60+
ENV GO_VERSION=1.19
61+
ENV GOPATH=$HOME/go-packages
62+
ENV GOROOT=$HOME/go
63+
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH
64+
RUN curl -fsSL https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz | tar xzs
65+
RUN echo 'export PATH=$GOPATH/bin:$PATH' >> $HOME/.bashrc
66+
67+
RUN bash -c ". $HOME/.bashrc \
68+
go install -v golang.org/x/tools/gopls@latest \
69+
&& go install -v mvdan.cc/sh/v3/cmd/shfmt@latest \
70+
"
71+
72+
# install nodejs
73+
RUN bash -c "$(curl -fsSL https://deb.nodesource.com/setup_14.x)" \
74+
&& apt-get install -y nodejs
75+
76+
# install zstd
77+
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/horta/zstd.install/main/install)"
78+
79+
# install nfpm
80+
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list \
81+
&& apt update \
82+
&& apt install nfpm
83+

.devcontainer/devcontainer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// For format details, see https://aka.ms/devcontainer.json
2+
{
3+
"name": "Development environments on your infrastructure",
4+
5+
// Sets the run context to one level up instead of the .devcontainer folder.
6+
"context": ".",
7+
8+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9+
"dockerFile": "Dockerfile",
10+
11+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
12+
// "forwardPorts": [],
13+
14+
"postStartCommand": "dockerd",
15+
16+
// privileged is required by GitHub codespaces - https://github.com/microsoft/vscode-dev-containers/issues/727
17+
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", "--privileged", "--init" ]
18+
}

.github/workflows/dependabot.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Dependabot is annoying, but this makes it a bit less so.
2+
name: Auto Approve Dependabot
3+
4+
on: pull_request_target
5+
6+
jobs:
7+
auto-approve:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
pull-requests: write
11+
steps:
12+
- uses: hmarr/auto-approve-action@v2
13+
if: github.actor == 'dependabot[bot]'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ vendor
1515
yarn-error.log
1616
gotests.coverage
1717
.idea
18+
.gitpod.yml
1819
.DS_Store
1920

2021
# Front-end ignore

.vscode/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"circbuf",
99
"cliflag",
1010
"cliui",
11+
"codecov",
12+
"Codespaces",
1113
"coderd",
1214
"coderdtest",
1315
"codersdk",
@@ -31,6 +33,7 @@
3133
"gonet",
3234
"gossh",
3335
"gsyslog",
36+
"GTTY",
3437
"hashicorp",
3538
"hclsyntax",
3639
"httpapi",
@@ -67,6 +70,7 @@
6770
"ntqry",
6871
"OIDC",
6972
"oneof",
73+
"opty",
7074
"paralleltest",
7175
"parameterscopeid",
7276
"pqtype",
@@ -76,7 +80,9 @@
7680
"provisionerd",
7781
"provisionersdk",
7882
"ptty",
83+
"ptys",
7984
"ptytest",
85+
"quickstart",
8086
"reconfig",
8187
"retrier",
8288
"rpty",
@@ -87,6 +93,7 @@
8793
"sourcemapped",
8894
"Srcs",
8995
"stretchr",
96+
"STTY",
9097
"stuntest",
9198
"tailbroker",
9299
"tailcfg",
@@ -105,17 +112,20 @@
105112
"tfjson",
106113
"tfplan",
107114
"tfstate",
115+
"tios",
108116
"tparallel",
109117
"trimprefix",
110118
"tsdial",
111119
"tslogger",
112120
"tstun",
113121
"turnconn",
114122
"typegen",
123+
"typesafe",
115124
"unconvert",
116125
"Untar",
117126
"Userspace",
118127
"VMID",
128+
"walkthrough",
119129
"weblinks",
120130
"webrtc",
121131
"wgcfg",
@@ -135,6 +145,10 @@
135145
"xstate",
136146
"yamux"
137147
],
148+
"cSpell.ignorePaths": [
149+
"site/package.json",
150+
".vscode/settings.json"
151+
],
138152
"emeraldwalk.runonsave": {
139153
"commands": [
140154
{

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ GOARCH := $(shell go env GOARCH)
3737
GOOS_BIN_EXT := $(if $(filter windows, $(GOOS)),.exe,)
3838
VERSION := $(shell ./scripts/version.sh)
3939

40+
# Use the highest ZSTD compression level in CI.
41+
ifdef CI
42+
ZSTDFLAGS := -22 --ultra
43+
else
44+
ZSTDFLAGS := -6
45+
endif
46+
4047
# All ${OS}_${ARCH} combos we build for. Windows binaries have the .exe suffix.
4148
OS_ARCHES := \
4249
linux_amd64 linux_arm64 linux_armv7 \
@@ -102,9 +109,8 @@ build/coder-slim_$(VERSION).tar: build/coder-slim_$(VERSION)_checksums.sha1 $(CO
102109
popd
103110

104111
build/coder-slim_$(VERSION).tar.zst site/out/bin/coder.tar.zst: build/coder-slim_$(VERSION).tar
105-
zstd -6 \
112+
zstd $(ZSTDFLAGS) \
106113
--force \
107-
--ultra \
108114
--long \
109115
--no-progress \
110116
-o "build/coder-slim_$(VERSION).tar.zst" \

agent/agent.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (a *agent) runStartupScript(ctx context.Context, script string) error {
320320
return nil
321321
}
322322

323-
writer, err := os.OpenFile(filepath.Join(os.TempDir(), "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0600)
323+
writer, err := os.OpenFile(filepath.Join(os.TempDir(), "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0o600)
324324
if err != nil {
325325
return xerrors.Errorf("open startup script log file: %w", err)
326326
}
@@ -415,6 +415,8 @@ func (a *agent) init(ctx context.Context) {
415415
},
416416
SubsystemHandlers: map[string]ssh.SubsystemHandler{
417417
"sftp": func(session ssh.Session) {
418+
session.DisablePTYEmulation()
419+
418420
server, err := sftp.NewServer(session)
419421
if err != nil {
420422
a.logger.Debug(session.Context(), "initialize sftp server", slog.Error(err))
@@ -539,7 +541,8 @@ func (a *agent) createCommand(ctx context.Context, rawCommand string, env []stri
539541
}
540542

541543
func (a *agent) handleSSHSession(session ssh.Session) (retErr error) {
542-
cmd, err := a.createCommand(session.Context(), session.RawCommand(), session.Environ())
544+
ctx := session.Context()
545+
cmd, err := a.createCommand(ctx, session.RawCommand(), session.Environ())
543546
if err != nil {
544547
return err
545548
}
@@ -556,32 +559,34 @@ func (a *agent) handleSSHSession(session ssh.Session) (retErr error) {
556559

557560
sshPty, windowSize, isPty := session.Pty()
558561
if isPty {
562+
// Disable minimal PTY emulation set by gliderlabs/ssh (NL-to-CRNL).
563+
// See https://github.com/coder/coder/issues/3371.
564+
session.DisablePTYEmulation()
565+
559566
cmd.Env = append(cmd.Env, fmt.Sprintf("TERM=%s", sshPty.Term))
560567

561568
// The pty package sets `SSH_TTY` on supported platforms.
562-
ptty, process, err := pty.Start(cmd)
569+
ptty, process, err := pty.Start(cmd, pty.WithPTYOption(
570+
pty.WithSSHRequest(sshPty),
571+
pty.WithLogger(slog.Stdlib(ctx, a.logger, slog.LevelInfo)),
572+
))
563573
if err != nil {
564574
return xerrors.Errorf("start command: %w", err)
565575
}
566576
defer func() {
567577
closeErr := ptty.Close()
568578
if closeErr != nil {
569-
a.logger.Warn(context.Background(), "failed to close tty",
570-
slog.Error(closeErr))
579+
a.logger.Warn(ctx, "failed to close tty", slog.Error(closeErr))
571580
if retErr == nil {
572581
retErr = closeErr
573582
}
574583
}
575584
}()
576-
err = ptty.Resize(uint16(sshPty.Window.Height), uint16(sshPty.Window.Width))
577-
if err != nil {
578-
return xerrors.Errorf("resize ptty: %w", err)
579-
}
580585
go func() {
581586
for win := range windowSize {
582587
resizeErr := ptty.Resize(uint16(win.Height), uint16(win.Width))
583588
if resizeErr != nil {
584-
a.logger.Warn(context.Background(), "failed to resize tty", slog.Error(resizeErr))
589+
a.logger.Warn(ctx, "failed to resize tty", slog.Error(resizeErr))
585590
}
586591
}
587592
}()
@@ -596,8 +601,7 @@ func (a *agent) handleSSHSession(session ssh.Session) (retErr error) {
596601
// ExitErrors just mean the command we run returned a non-zero exit code, which is normal
597602
// and not something to be concerned about. But, if it's something else, we should log it.
598603
if err != nil && !xerrors.As(err, &exitErr) {
599-
a.logger.Warn(context.Background(), "wait error",
600-
slog.Error(err))
604+
a.logger.Warn(ctx, "wait error", slog.Error(err))
601605
}
602606
return err
603607
}

agent/agent_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func TestAgent(t *testing.T) {
503503
DERPMap: derpMap,
504504
}, 0)
505505
defer conn.Close()
506-
res, err := conn.Speedtest(speedtest.Upload, speedtest.MinDuration)
506+
res, err := conn.Speedtest(speedtest.Upload, 250*time.Millisecond)
507507
require.NoError(t, err)
508508
t.Logf("%.2f MBits/s", res[len(res)-1].MBitsPerSecond())
509509
})

cli/cliflag/cliflag.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ func StringVarP(flagset *pflag.FlagSet, p *string, name string, shorthand string
6161
flagset.StringVarP(p, name, shorthand, v, fmtUsage(usage, env))
6262
}
6363

64+
func StringArray(flagset *pflag.FlagSet, name, shorthand, env string, def []string, usage string) {
65+
v, ok := os.LookupEnv(env)
66+
if !ok || v == "" {
67+
if v == "" {
68+
def = []string{}
69+
} else {
70+
def = strings.Split(v, ",")
71+
}
72+
}
73+
flagset.StringArrayP(name, shorthand, def, fmtUsage(usage, env))
74+
}
75+
6476
func StringArrayVarP(flagset *pflag.FlagSet, ptr *[]string, name string, shorthand string, env string, def []string, usage string) {
6577
val, ok := os.LookupEnv(env)
6678
if ok {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy