Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
Proxy
Commits
68324caa
Commit
68324caa
authored
4 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://gitlab.metager.de/open-source/Proxy
parents
2ac0a04e
67994b7f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Dockerfile
+1
-0
1 addition, 0 deletions
Dockerfile
app/Console/Commands/RequestFetcher.php
+7
-12
7 additions, 12 deletions
app/Console/Commands/RequestFetcher.php
app/Http/Controllers/ProxyController.php
+11
-8
11 additions, 8 deletions
app/Http/Controllers/ProxyController.php
with
19 additions
and
20 deletions
Dockerfile
+
1
−
0
View file @
68324caa
...
...
@@ -21,6 +21,7 @@ RUN apk add --update \
php7-dom
\
php7-fileinfo
\
php7-redis
\
&&
apk upgrade
-u
-a
\
&&
rm
-rf
/var/cache/apk/
*
\
&&
update-ca-certificates
...
...
This diff is collapsed.
Click to expand it.
app/Console/Commands/RequestFetcher.php
+
7
−
12
View file @
68324caa
...
...
@@ -10,7 +10,7 @@ use Log;
class
RequestFetcher
extends
Command
{
public
const
FETCHQUEUE_KEY
=
"fetcher.queue"
;
public
const
SIZE_LIMIT
=
2
*
1024
*
1024
;
// Limit Document Size to 2MB
public
const
SIZE_LIMIT
=
2
0
*
1024
*
1024
;
// Limit Document Size to 2MB
/**
* The name and signature of the console command.
...
...
@@ -146,16 +146,11 @@ class RequestFetcher extends Command
$infos
=
explode
(
";"
,
$infos
);
$resulthash
=
$infos
[
0
];
$cacheDurationMinutes
=
intval
(
$infos
[
1
]);
$responseCode
=
curl_getinfo
(
$info
[
"handle"
],
CURLINFO_HTTP_CODE
);
$body
=
"no-result"
;
$totalTime
=
curl_getinfo
(
$info
[
"handle"
],
CURLINFO_TOTAL_TIME
);
$error
=
curl_error
(
$info
[
"handle"
]);
if
(
!
empty
(
$error
))
{
Log
::
error
(
$error
);
if
(
curl_errno
(
$info
[
"handle"
])){
Log
::
error
(
curl_error
(
$info
[
"handle"
]));
}
$result
=
$this
->
parseResponse
(
$info
[
"handle"
]);
Redis
::
pipeline
(
function
(
$pipe
)
use
(
$resulthash
,
$result
,
$cacheDurationMinutes
)
{
...
...
@@ -243,11 +238,11 @@ class RequestFetcher extends Command
CURLOPT_RETURNTRANSFER
=>
1
,
CURLOPT_USERAGENT
=>
$job
[
"useragent"
],
CURLOPT_FOLLOWLOCATION
=>
true
,
CURLOPT_CONNECTTIMEOUT
=>
2
,
CURLOPT_CONNECTTIMEOUT
=>
10
,
CURLOPT_MAXCONNECTS
=>
500
,
CURLOPT_LOW_SPEED_LIMIT
=>
50000
,
CURLOPT_LOW_SPEED_TIME
=>
5
,
CURLOPT_TIMEOUT
=>
7
,
CURLOPT_TIMEOUT
=>
20
,
CURLOPT_HEADER
=>
true
,
CURLOPT_NOPROGRESS
=>
false
,
CURLOPT_PROGRESSFUNCTION
=>
'self::progress'
,
...
...
This diff is collapsed.
Click to expand it.
app/Http/Controllers/ProxyController.php
+
11
−
8
View file @
68324caa
...
...
@@ -156,7 +156,7 @@ class ProxyController extends Controller
$mission
=
[
"resulthash"
=>
$hash
,
"url"
=>
$this
->
sanitizeUrl
(
$targetUrl
),
"url"
=>
self
::
sanitizeUrl
(
$targetUrl
),
"useragent"
=>
$useragent
,
"cacheDuration"
=>
$this
::
PROXY_CACHE
,
];
...
...
@@ -373,18 +373,21 @@ class ProxyController extends Controller
*/
public
static
function
generateProxyWrapperUrl
(
$url
){
$password
=
self
::
generatePassword
(
$url
,
null
);
$sanitizedUrl
=
self
::
sanitizeUrl
(
$url
);
$
p
arts
=
parse_url
(
$
u
rl
);
$
sanitizedP
arts
=
parse_url
(
$
sanitizedU
rl
);
$host
=
null
;
$path
=
null
;
if
(
!
empty
(
$
p
arts
[
"host"
])){
$host
=
$
p
arts
[
"host"
];
if
(
!
empty
(
$
sanitizedP
arts
[
"host"
])){
$host
=
$
sanitizedP
arts
[
"host"
];
}
if
(
!
empty
(
$
p
arts
[
"path"
])){
$path
=
trim
(
$
p
arts
[
"path"
],
"/"
);
if
(
!
empty
(
$
sanitizedP
arts
[
"path"
])){
$path
=
trim
(
$
sanitizedP
arts
[
"path"
],
"/"
);
}
$parameters
=
[
"host"
=>
$host
,
"path"
=>
$path
,
...
...
@@ -504,7 +507,7 @@ class ProxyController extends Controller
}
}
private
function
sanitizeUrl
(
$url
){
private
static
function
sanitizeUrl
(
$url
){
$parts
=
parse_url
(
$url
);
// Optional but we only sanitize URLs with scheme and host defined
...
...
@@ -525,7 +528,7 @@ class ProxyController extends Controller
// Build the url
$targetUrl
=
$parts
[
"scheme"
]
.
"://"
.
((
!
empty
(
$parts
[
"user"
])
&&
!
empty
(
$parts
[
"pass"
]))
?
$parts
[
"user"
]
.
":"
.
$parts
[
"pass"
]
.
"@"
:
""
)
.
$parts
[
"host"
]
.
rtrim
(
$parts
[
"host"
]
,
"."
)
.
"."
.
(
!
empty
(
$parts
[
"port"
])
?
":"
.
$parts
[
"port"
]
:
""
)
.
(
!
empty
(
$sanitizedPath
)
?
$sanitizedPath
:
""
)
.
(
!
empty
(
$parts
[
"query"
])
?
"?"
.
$parts
[
"query"
]
:
""
)
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment