Added support for using Hurl through a Proxy. #41

Open
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+387 −1
Diff settings

Always

Just for now

View
@@ -1,3 +1,4 @@
db/
.bundle/
bin/
+.DS_Store
View
@@ -38,6 +38,28 @@ Run Locally
Now visit <http://localhost:9393>
+Proxy Support
+-------------
+
+Run hurl through a proxy by just adding the URL and port of the proxy.
+
+Use a public proxy from: http://www.hidemyass.com/proxy-list/
+
+or create a proxy tunnel to a secure server:
+
+ ssh -D <port> -f -C -v -N <username>@<some.proxy.server>
+
+
+
+For example, if I used HideMyAss IP and Port, the UI would look like this:
+
+[![Hide My Ass](https://img.skitch.com/20110519-fq6rercxgy4xt5wtkxt5y3q3s8.jpg)](https://img.skitch.com/20110519-fq6rercxgy4xt5wtkxt5y3q3s8.jpg)
+
+and if I use a proxy tunnel with socks5 and port 9999 with the ssh command above, the UI would look like this:
+
+[![Proxy](https://img.skitch.com/20110519-frcu27a2rd455381mb4s3a5a4g.jpg)](https://img.skitch.com/20110519-frcu27a2rd455381mb4s3a5a4g.jpg)
+
+
Issues
------
View
@@ -123,10 +123,23 @@ def initialize(*args)
return json(:error => "Calm down and try my margarita!") if rate_limited?
url, method, auth = params.values_at(:url, :method, :auth)
+ proxy_url, proxy_port, proxy_socks5 = params.values_at(:proxy_url, :proxy_port, :use_socks_5)
return json(:error => "That's... wait.. what?!") if invalid_url?(url)
- curl = Curl::Easy.new(url)
+ if !proxy_url.nil?
+ # proxy = "localhost:9999"
+ # http://curb.rubyforge.org/svn/BRANCHES/curb-multi/ext/curb.c
+ curl = Curl::Easy.new(url) do |curl|
+ curl.proxy_url = "#{proxy_url}:#{proxy_port}"
+ curl.proxy_type = 5 if proxy_socks5
+ curl.follow_location = true
+ curl.ssl_verify_peer = false
+ curl.max_redirects = 3
+ end
+ else
+ curl = Curl::Easy.new(url)
+ end
sent_headers = []
curl.on_debug do |type, data|
@@ -63,7 +63,15 @@
<textarea rows="15" name="post-body">{{ hurl_post_body }}</textarea>
</p>
</div>
+
+ <a id="use-proxy" href="#"><span class="link-icon">+</span> use proxy</a>
+ <div id="proxy-fields" {{^ hurl_use_proxy}}style="display:none;"{{/ hurl_use_proxy}}>
+ <input type="text" name="proxy_url" id="proxy-url" class="form-alpha" title="url"/>
+ <input type="text" name="proxy_port" id="proxy-port" class="form-beta" title="port"/>
+ <div id="socks_5_container"><input type="checkbox" name="use_socks_5" value="1" id="use_socks_5"></div>
+ </div>
</p>
+
<p id="auth-selection">
<label>
<input type="radio" name="auth" value="none" checked="checked"/>
@@ -16,8 +16,11 @@
<link rel="stylesheet" type="text/css" href="/css/pygment_trac.css">
<link rel="stylesheet" type="text/css" href="/css/jquery.autocomplete.css">
<link rel="stylesheet" type="text/css" href="/css/facebox.css">
+ <link rel="stylesheet" type="text/css" href="/css/iphone-style-checkboxes.css">
+
<script src="/js/jquery.js" type="text/javascript"></script>
+ <script src="/js/iphone-style-checkboxes.js" type="text/javascript"></script>
<script src="/js/facebox.js"type="text/javascript"></script>
<script src="/js/hurl.headers.js" type="text/javascript"></script>
<script src="/js/hurl.js" type="text/javascript"></script>
View
@@ -44,6 +44,10 @@ def hurl_post_body
@hurl['post-body'] if @hurl
end
+ def hurl_use_proxy
+ @hurl['proxy-url'] if @hurl
+ end
+
def hurl_url
@hurl['url'] if @hurl
end
@@ -0,0 +1,77 @@
+
+.iPhoneCheckContainer {
+ position: relative;
+ height: 27px;
+ cursor: pointer;
+ overflow: hidden;
+}
+ .iPhoneCheckContainer input {
+ position: absolute;
+ top: 5px;
+ left: 30px;
+ opacity: 0;
+ -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); }
+ .iPhoneCheckContainer label {
+ white-space: nowrap;
+ font-size: 17px;
+ line-height: 17px;
+ font-weight: bold;
+ font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
+ text-transform: uppercase;
+ cursor: pointer;
+ display: block;
+ height: 27px;
+ position: absolute;
+ width: auto;
+ top: 0;
+ padding-top: 5px;
+ overflow: hidden; }
+ .iPhoneCheckContainer, .iPhoneCheckContainer label {
+ user-select: none;
+ -moz-user-select: none;
+ -khtml-user-select: none; }
+
+.iPhoneCheckDisabled {
+ opacity: 0.5;
+ -ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50);
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=50); }
+
+label.iPhoneCheckLabelOn {
+ color: white;
+ background: url('/img/iphone-style-checkboxes/on.png?1282083753') no-repeat;
+ text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.6);
+ left: 0;
+ padding-top: 5px; }
+ label.iPhoneCheckLabelOn span {
+ padding-left: 8px; }
+label.iPhoneCheckLabelOff {
+ color: #8b8b8b;
+ background: url('/img/iphone-style-checkboxes/off.png?1282083753') no-repeat right 0;
+ text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.6);
+ text-align: right;
+ right: 0; }
+ label.iPhoneCheckLabelOff span {
+ padding-right: 8px; }
+
+.iPhoneCheckHandle {
+ display: block;
+ height: 27px;
+ cursor: pointer;
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 0;
+ background: url('/img/iphone-style-checkboxes/slider_left.png?1282083753') no-repeat;
+ padding-left: 3px; }
+
+.iPhoneCheckHandleRight {
+ height: 100%;
+ width: 100%;
+ padding-right: 3px;
+ background: url('/img/iphone-style-checkboxes/slider_right.png?1282083753') no-repeat right 0; }
+
+.iPhoneCheckHandleCenter {
+ height: 100%;
+ width: 100%;
+ background: url('/img/iphone-style-checkboxes/slider_center.png?1282083753'); }
View
@@ -1,3 +1,4 @@
+
/* general */
body {
font: 1em "lucida Grande",arial,sans-serif;
@@ -67,6 +68,21 @@ input[type=password].form-beta {
.form-beta {
margin-left: 6px !important;
}
+
+#proxy-url{
+ width: 387px;
+}
+#proxy-port{
+ width: 79px;
+}
+#socks_5_container{
+ display: inline;
+ width: 98px;
+ margin-top: 3px;
+ float: right;
+ margin-right: 150px;
+}
+
/* buttons */
button {
font: 1em "Helvetica Neue", Arial, sans-serif;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
@@ -177,6 +177,18 @@ $(document).ready(function() {
return false
})
+ $('#use-proxy').click(function() {
+ if ($('#proxy-fields').css('display') == 'block'){
+ $('#proxy-fields').css({'display' : 'none'});
+ $('#use-proxy').html('+ use proxy');
+ }else {
+ $('#proxy-fields').css({'display' : 'block'});
+ $('#socks_5_container :checkbox').iphoneStyle({ checkedLabel: 'Socks 5 On', uncheckedLabel: 'Socks 5 Off' });
+ $('#use-proxy').html('- do not use proxy');
+ }
+ return false;
+ })
+
// remove header / param
function registerRemoveHandlers(el, klass) {
$(el).find(klass).click(function() {
@@ -258,4 +270,5 @@ $(document).ready(function() {
// relatize dates
$('.relatize').relatizeDate()
+
});
Oops, something went wrong.