Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
image board
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
random asynchronous nightmare distributor
image board
Commits
8c05fe43
Commit
8c05fe43
authored
3 years ago
by
Ophestra
Browse files
Options
Downloads
Patches
Plain Diff
return error properly after reading metadata, add TrustedProxies as a configuration entry
parent
9e1d5a05
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
backend/filesystem/image.go
+10
-4
10 additions, 4 deletions
backend/filesystem/image.go
config.go
+10
-4
10 additions, 4 deletions
config.go
web.go
+4
-1
4 additions, 1 deletion
web.go
with
24 additions
and
9 deletions
backend/filesystem/image.go
+
10
−
4
View file @
8c05fe43
...
@@ -398,8 +398,11 @@ func (s *Store) ImageSnowflakeHash(flake string) (string, error) {
...
@@ -398,8 +398,11 @@ func (s *Store) ImageSnowflakeHash(flake string) (string, error) {
}
}
if
!
s
.
Compat
{
if
!
s
.
Compat
{
img
,
err
:=
s
.
imageMetadataRead
(
s
.
ImageSnowflakePath
(
flake
)
+
"/"
+
infoJson
)
if
img
,
err
:=
s
.
imageMetadataRead
(
s
.
ImageSnowflakePath
(
flake
)
+
"/"
+
infoJson
);
err
!=
nil
{
return
img
.
Hash
,
err
return
""
,
err
}
else
{
return
img
.
Hash
,
nil
}
}
else
{
}
else
{
if
path
,
err
:=
os
.
ReadFile
(
s
.
ImageSnowflakePath
(
flake
));
err
!=
nil
{
if
path
,
err
:=
os
.
ReadFile
(
s
.
ImageSnowflakePath
(
flake
));
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
...
@@ -408,8 +411,11 @@ func (s *Store) ImageSnowflakeHash(flake string) (string, error) {
...
@@ -408,8 +411,11 @@ func (s *Store) ImageSnowflakeHash(flake string) (string, error) {
return
""
,
err
return
""
,
err
}
else
{
}
else
{
var
img
*
store
.
Image
var
img
*
store
.
Image
img
,
err
=
s
.
imageMetadataRead
(
string
(
path
)
+
"/"
+
infoJson
)
if
img
,
err
=
s
.
imageMetadataRead
(
string
(
path
)
+
"/"
+
infoJson
);
err
!=
nil
{
return
img
.
Hash
,
err
return
""
,
err
}
else
{
return
img
.
Hash
,
nil
}
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
config.go
+
10
−
4
View file @
8c05fe43
...
@@ -14,10 +14,11 @@ type conf struct {
...
@@ -14,10 +14,11 @@ type conf struct {
}
}
type
serverConf
struct
{
type
serverConf
struct
{
Host
string
`toml:"host"`
Host
string
`toml:"host"`
Unix
bool
`toml:"unix"`
Unix
bool
`toml:"unix"`
Port
uint16
`toml:"port"`
Port
uint16
`toml:"port"`
Proxy
bool
`toml:"proxy"`
Proxy
bool
`toml:"proxy"`
TrustedProxies
[]
string
`toml:"trusted_proxies"`
}
}
type
systemConf
struct
{
type
systemConf
struct
{
...
@@ -79,5 +80,10 @@ var defConf = conf{
...
@@ -79,5 +80,10 @@ var defConf = conf{
Unix
:
false
,
Unix
:
false
,
Port
:
7777
,
Port
:
7777
,
Proxy
:
true
,
Proxy
:
true
,
TrustedProxies
:
[]
string
{
"10.0.0.0/8"
,
"172.16.0.0/12"
,
"192.168.0.0/16"
,
},
},
},
}
}
This diff is collapsed.
Click to expand it.
web.go
+
4
−
1
View file @
8c05fe43
...
@@ -27,10 +27,13 @@ func webSetup() {
...
@@ -27,10 +27,13 @@ func webSetup() {
}
}
router
=
gin
.
New
()
router
=
gin
.
New
()
router
.
Use
(
recovery
())
router
.
ForwardedByClientIP
=
config
.
Server
.
Proxy
router
.
ForwardedByClientIP
=
config
.
Server
.
Proxy
router
.
TrustedProxies
=
config
.
Server
.
TrustedProxies
if
config
.
System
.
Verbose
{
if
config
.
System
.
Verbose
{
router
.
Use
(
gin
.
Logger
())
router
.
Use
(
gin
.
Logger
())
router
.
Use
(
gin
.
Recovery
())
}
else
{
router
.
Use
(
recovery
())
}
}
router
.
NoRoute
(
func
(
context
*
gin
.
Context
)
{
router
.
NoRoute
(
func
(
context
*
gin
.
Context
)
{
context
.
Redirect
(
http
.
StatusTemporaryRedirect
,
"/web"
)
context
.
Redirect
(
http
.
StatusTemporaryRedirect
,
"/web"
)
...
...
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