Skip to content

Commit 38c5d47

Browse files
authored
Merge branch 'main' into jo/direct-tcpip-server
2 parents 0eb5a75 + f265b4e commit 38c5d47

30 files changed

Lines changed: 755 additions & 144 deletions
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: Joannis
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**Reproducer Sample**
14+
Code that reproduces the issue. Omit credentials.
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Client (please complete the following information):**
20+
- OS: [e.g. iOS, macOS Sonoma, Ubuntu 23.04]
21+
- Client: [e.g. openssh, Citadel]
22+
- Version of Citadel, if applicable:
23+
24+
**Server (please complete the following information):**
25+
- OS: [e.g. iOS, macOS Sonoma, Ubuntu 23.04]
26+
- Server: [e.g. opensshd, Citadel]
27+
- Version of Citadel, if applicable:
28+
29+
**Additional context**
30+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: Joannis
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context about the feature request here.

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: test
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
5+
on:
6+
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
7+
push: { branches: [main] }
8+
9+
env:
10+
LOG_LEVEL: info
11+
SWIFT_DETERMINISTIC_HASHING: 1
12+
jobs:
13+
test:
14+
services:
15+
ssh-server:
16+
image: lscr.io/linuxserver/openssh-server:latest
17+
ports:
18+
- 2222:2222
19+
env:
20+
USER_NAME: citadel
21+
USER_PASSWORD: hunter2
22+
PASSWORD_ACCESS: true
23+
runs-on: ubuntu-latest
24+
container:
25+
image: swift:5.10-jammy
26+
env:
27+
SWIFT_DETERMINISTIC_HASHING: 1
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Resolve
31+
run: swift package resolve
32+
- name: Run tests
33+
run: swift test
34+
env:
35+
SWIFT_DETERMINISTIC_HASHING: 1
36+
SSH_HOST: ssh-server
37+
SSH_PORT: 2222
38+
SSH_USERNAME: citadel
39+
SSH_PASSWORD: hunter2

Examples/ExampleClient/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"configurations": [
3+
{
4+
"type": "lldb",
5+
"request": "launch",
6+
"sourceLanguages": ["swift"],
7+
"args": [],
8+
"cwd": "${workspaceFolder:ExampleClient}",
9+
"name": "Debug ExampleClient",
10+
"program": "${workspaceFolder:ExampleClient}/.build/debug/ExampleClient",
11+
"preLaunchTask": "swift: Build Debug ExampleClient"
12+
},
13+
{
14+
"type": "lldb",
15+
"request": "launch",
16+
"sourceLanguages": ["swift"],
17+
"args": [],
18+
"cwd": "${workspaceFolder:ExampleClient}",
19+
"name": "Release ExampleClient",
20+
"program": "${workspaceFolder:ExampleClient}/.build/release/ExampleClient",
21+
"preLaunchTask": "swift: Build Release ExampleClient"
22+
}
23+
]
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ubuntu:latest
2+
3+
RUN apt update && apt install openssh-server sudo -y
4+
5+
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 test
6+
7+
RUN echo 'test:test' | chpasswd
8+
9+
RUN service ssh start
10+
11+
EXPOSE 22
12+
13+
CMD ["/usr/sbin/sshd","-D"]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// swift-tools-version: 5.9
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "ExampleClient",
8+
platforms: [
9+
.macOS(.v12),
10+
],
11+
dependencies: [
12+
.package(path: "../../"),
13+
],
14+
targets: [
15+
// Targets are the basic building blocks of a package, defining a module or a test suite.
16+
// Targets can depend on other targets in this package and products from dependencies.
17+
.executableTarget(
18+
name: "ExampleClient",
19+
dependencies: [
20+
.product(name: "Citadel", package: "Citadel"),
21+
]
22+
),
23+
]
24+
)

Examples/ExampleClient/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1. Build the dockerfile using `docker build --file ExampleServer.dockerfile --tag sshd-example .`
2+
2. Run the docker image using `docker run -p 2323:22 sshd-example`
3+
3. Run this Swift code to connect tom the server and run a command using `swift run`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Citadel
2+
3+
let client = try await SSHClient.connect(
4+
host: "localhost",
5+
port: 2323,
6+
authenticationMethod: .passwordBased(username: "test", password: "test"),
7+
hostKeyValidator: .acceptAnything(),
8+
reconnect: .never
9+
)
10+
11+
let result = try await client.executeCommand("echo 'Hello, World!'")
12+
print(String(buffer: result))

Examples/OpenSSH/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
FROM ubuntu:latest
3+
4+
RUN apt update && apt install openssh-server sudo -y
5+
6+
RUN echo "ubuntu:test" | chpasswd
7+
8+
RUN service ssh start
9+
10+
EXPOSE 22
11+
12+
CMD ["/usr/sbin/sshd","-D"]

0 commit comments

Comments
 (0)