Skip to content

Commit

Permalink
Limit transfer speeds of server files, attempt to fix ping spikes cau…
Browse files Browse the repository at this point in the history
…sed by very fast uploads
  • Loading branch information
Arie committed Jun 29, 2023
1 parent 615dfc6 commit c056f68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/ssh_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ def supports_mitigations?
private

def scp_command
'scp -T'
'scp -T -l 200000'
end
end
10 changes: 7 additions & 3 deletions spec/models/ssh_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
describe '#find_process_id' do
it 'finds correct pid' do
subject.stub(port: '27015')
subject.should_receive(:execute).with("ps ux | grep port | grep #{subject.port} | grep srcds_linux | grep -v grep | grep -v ruby | awk '{print \$2}'")
subject.should_receive(:execute).with("ps ux | grep port | grep #{subject.port} | grep srcds_linux | grep -v grep | grep -v ruby | awk '{print $2}'")
subject.find_process_id
end
end
Expand Down Expand Up @@ -110,7 +110,7 @@
files = [File.join('foo')]
destination = 'bar'

subject.should_receive('system').with("scp -T foo #{subject.ip}:bar")
subject.should_receive('system').with("#{scp_command} foo #{subject.ip}:bar")
subject.copy_to_server(files, destination)
end
end
Expand All @@ -133,7 +133,7 @@
files = [File.join('foo')]
destination = 'bar'

subject.should_receive(:system).with("scp -T #{subject.ip}:\"foo\" bar")
subject.should_receive(:system).with("#{scp_command} #{subject.ip}:\"foo\" bar")

subject.copy_from_server(files, destination)
end
Expand All @@ -156,4 +156,8 @@
subject.shell_output_to_array(shell_output).first.should_not include("\n")
end
end

def scp_command
'scp -T -l 200000'
end
end

0 comments on commit c056f68

Please sign in to comment.