Skip to content

Commit

Permalink
Release 1.4 (#16)
Browse files Browse the repository at this point in the history
* add more error handling and logging

* vscode ruby-lsp

* updates

* Gem updates

* Release 1.4
  • Loading branch information
mhyllander authored Jan 11, 2024
1 parent 82902f6 commit 779d449
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
uses: actions/checkout@v2

- name: Build tar.gz
run: tar zcf gpgbridge.tar.gz gpgbridge.rb Gemfile README.md ReleaseNotes.md
run: tar zcf gpgbridge.tar.gz gpgbridge.rb Gemfile Gemfile.lock README.md ReleaseNotes.md

- name: Build zip
run: zip gpgbridge.zip gpgbridge.rb Gemfile README.md ReleaseNotes.md
run: zip gpgbridge.zip gpgbridge.rb Gemfile Gemfile.lock README.md ReleaseNotes.md

- name: Create release
id: create_release
Expand All @@ -35,7 +35,7 @@ jobs:
prerelease: ${{ contains(github.ref, '-pre') }}

- name: Upload tar.gz
uses: actions/upload-release-asset@v1.0.2
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -45,7 +45,7 @@ jobs:
asset_content_type: application/gzip

- name: Upload zip
uses: actions/upload-release-asset@v1.0.2
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
#*
Gemfile.lock
**/vendor/bundle
**/.bundle
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inherit_from:
- <%= ENV['HOME'] %>/.config/rubocop/config.yml
9 changes: 9 additions & 0 deletions .vscode/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file can be used with the "ruby-lsp" extension in VS Code.
# Set "Bundle Gemfile" in the "Ruby LSP" Workspace settings to "./.Gemfile.dev"

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gem 'ruby-lsp'
gem 'rubocop'
gem 'rubocop-performance'
49 changes: 49 additions & 0 deletions .vscode/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
json (2.7.1)
language_server-protocol (3.17.0.3)
parallel (1.24.0)
parser (3.3.0.2)
ast (~> 2.4.1)
racc
prism (0.19.0)
racc (1.7.3)
rainbow (3.1.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.59.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-lsp (0.13.2)
language_server-protocol (~> 3.17.0)
prism (>= 0.19.0, < 0.20)
sorbet-runtime (>= 0.5.5685)
ruby-progressbar (1.13.0)
sorbet-runtime (0.5.11188)
unicode-display_width (2.5.0)

PLATFORMS
x86_64-linux

DEPENDENCIES
rubocop
rubocop-performance
ruby-lsp

BUNDLED WITH
2.4.10
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rubyLsp.bundleGemfile": ".vscode/Gemfile"
}
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'sys-proctable', '~> 1.2.5'
gem 'ptools', '~> 1.3.7', platforms: :ruby
gem 'net-ssh', '~> 6.1.0', platforms: :x64_mingw
gem 'sys-proctable', '~> 1.3.0'
gem 'ptools', '~> 1.5.0', platforms: :ruby
gem 'net-ssh', '~> 7.2.1', platforms: :x64_mingw
18 changes: 18 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
GEM
remote: https://rubygems.org/
specs:
ffi (1.16.3)
ptools (1.5.0)
sys-proctable (1.3.0)
ffi (~> 1.1)

PLATFORMS
x86_64-linux

DEPENDENCIES
net-ssh (~> 7.2.1)
ptools (~> 1.5.0)
sys-proctable (~> 1.3.0)

BUNDLED WITH
2.4.10
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Changes in v1.4

* Verified with ruby 3.2 & 3.3, and updated gems.

## Changes in v1.3

* Updates to the helper functions to support zsh (contributed by @tetov).
52 changes: 34 additions & 18 deletions gpgbridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
FIRST_PORT = 6910
BUFSIZ = 4096

# WslBridge runs in WSL. It receives requests through local sockets
# requests from WSL clients and forwards them to WindowsBridge in Windows.
# WslBridge runs in WSL. It receives requests from WSL clients through
# local sockets and forwards them to WindowsBridge in Windows.
class WslBridge
def initialize(options, logger)
@pidfile = options[:pidfile]
Expand Down Expand Up @@ -96,10 +96,16 @@ def start_listener(socket_name, remote_address, port, noncefile)
Thread.new do
# get WindowsBridge nonce
nonce = get_nonce noncefile
@logger.debug 'connect with remote'
winbridge = TCPSocket.new remote_address, port
# send the nonce to authenticate, if the nonce is wrong the connection will be closed immediately
winbridge.send nonce, 0
winbridge = nil
begin
@logger.debug 'connect with winbridge'
winbridge = TCPSocket.new remote_address, port
# send the nonce to authenticate, if the nonce is wrong the connection will be closed immediately
winbridge.send nonce, 0
rescue Errno::ETIMEDOUT => e
@logger.error "Exception while connecting with winbridge: #{e.inspect}"
Thread.exit
end
@logger.debug 'connected'
begin
loop = true
Expand All @@ -108,20 +114,30 @@ def start_listener(socket_name, remote_address, port, noncefile)
readable = ready[0]
if readable.include?(sock)
@logger.debug 'msg from client'
msg = sock.recv BUFSIZ
if msg.length > 0
winbridge.send msg, 0
else
loop = false
begin
msg = sock.recv BUFSIZ
if msg.length > 0
winbridge.send msg, 0
else
loop = false
end
rescue Errno::ECONNRESET => e
@logger.error "Exception while receiving msg from client: #{e.inspect}"
Thread.exit
end
end
if readable.include?(winbridge)
@logger.debug 'msg from bridge'
msg = winbridge.recv BUFSIZ
if msg.length > 0
sock.send msg, 0
else
loop = false
@logger.debug 'msg from winbridge'
begin
msg = winbridge.recv BUFSIZ
if msg.length > 0
sock.send msg, 0
else
loop = false
end
rescue Errno::ECONNRESET => e
@logger.error "Exception while receiving msg from winbridge: #{e.inspect}"
Thread.exit
end
end
end
Expand Down Expand Up @@ -191,7 +207,7 @@ def initialize(options, logger)
socket_names = options[:socket_names]
@threads = socket_names.collect do |socket_name, port|
Thread.start(socket_name, remote_address, port, nonce) do |s, r, p, n|
if socket_name == 'agent-ssh-socket'
if s == 'agent-ssh-socket'
start_pageant_proxy s, r, p, n
else
start_assuan_proxy s, r, p, n
Expand Down

0 comments on commit 779d449

Please sign in to comment.