Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webconsole
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
pqc-free5gc
webconsole
Commits
21055d60
Unverified
Commit
21055d60
authored
11 months ago
by
CTFang@WireLab
Browse files
Options
Downloads
Patches
Plain Diff
feat: use config file in billing server
parent
8553d72c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/billing/server.go
+25
-38
25 additions, 38 deletions
backend/billing/server.go
backend/factory/config.go
+14
-7
14 additions, 7 deletions
backend/factory/config.go
config/webuicfg.yaml
+8
-3
8 additions, 3 deletions
config/webuicfg.yaml
with
47 additions
and
48 deletions
backend/billing/server.go
+
25
−
38
View file @
21055d60
...
...
@@ -4,10 +4,12 @@ package billing
import
(
"encoding/json"
"os"
"path"
"strconv"
"sync"
"github.com/fclairamb/ftpserver/config"
ftpconf
"github.com/fclairamb/ftpserver/config/confpar"
"github.com/fclairamb/ftpserver/server"
ftpserver
"github.com/fclairamb/ftpserverlib"
...
...
@@ -21,55 +23,40 @@ type BillingDomain struct {
wg
*
sync
.
WaitGroup
}
type
Access
struct
{
User
string
`json:"user"`
Pass
string
`json:"pass"`
Fs
string
`json:"fs"`
Params
map
[
string
]
string
`json:"params"`
}
type
PortRange
struct
{
Start
int
`json:"start"`
End
int
`json:"end"`
}
type
FtpConfig
struct
{
Version
int
`json:"version"`
Accesses
[]
Access
`json:"accesses"`
Listen_address
string
`json:"listen_address"`
Passive_transfer_port_range
PortRange
`json:"passive_transfer_port_range"`
}
// The ftp server is for CDR Push method, that is the CHF will send the CDR file to the FTP server
func
OpenServer
(
wg
*
sync
.
WaitGroup
)
*
BillingDomain
{
// Arguments vars
confFile
:=
"/tmp/webconsole/ftpserver.json"
b
:=
&
BillingDomain
{
wg
:
wg
,
}
if
_
,
err
:=
os
.
Stat
(
"/tmp/webconsole"
);
err
!=
nil
{
if
err_mk
:=
os
.
Mkdir
(
"/tmp/webconsole"
,
os
.
ModePerm
);
err_mk
!=
nil
{
billingConfig
:=
factory
.
WebuiConfig
.
Configuration
.
BillingServer
basePath
:=
billingConfig
.
BastPath
confFile
:=
path
.
Join
(
basePath
,
"ftpserver.json"
)
if
_
,
err
:=
os
.
Stat
(
basePath
);
err
!=
nil
{
if
err_mk
:=
os
.
Mkdir
(
basePath
,
os
.
ModePerm
);
err_mk
!=
nil
{
logger
.
BillingLog
.
Error
(
err_mk
)
}
}
billingConfig
:=
factory
.
WebuiConfig
.
Configuration
.
BillingServer
addr
:=
billingConfig
.
HostIPv4
+
":"
+
strconv
.
Itoa
(
billingConfig
.
ListenPort
)
params
:=
map
[
string
]
string
{
"basePath"
:
"/tmp/webconsole"
,
"basePath"
:
basePath
,
}
if
billingConfig
.
Tls
!=
nil
{
params
[
"cert"
]
=
billingConfig
.
Tls
.
Pem
params
[
"key"
]
=
billingConfig
.
Tls
.
Key
logger
.
BillingLog
.
Infof
(
"Open BillingServer on %+v"
,
basePath
)
if
billingConfig
.
Cert
!=
nil
{
params
[
"cert"
]
=
billingConfig
.
Cert
.
Pem
params
[
"key"
]
=
billingConfig
.
Cert
.
Key
logger
.
BillingLog
.
Infof
(
"Use tls: %+v, %+v"
,
params
[
"cert"
],
params
[
"key"
])
}
ftpConfig
:=
F
tp
C
onf
ig
{
ftpConfig
:=
f
tp
c
onf
.
Content
{
Version
:
1
,
Accesses
:
[]
Access
{
Accesses
:
[]
*
ftpconf
.
Access
{
{
User
:
"admin"
,
Pass
:
"free5gc"
,
...
...
@@ -77,11 +64,11 @@ func OpenServer(wg *sync.WaitGroup) *BillingDomain {
Params
:
params
,
},
},
Passive
_t
ransfer
_p
ort
_r
ange
:
PortRange
{
Start
:
2123
,
End
:
2130
,
Passive
T
ransfer
P
ort
R
ange
:
&
ftpconf
.
PortRange
{
Start
:
billingConfig
.
PortRange
.
Start
,
End
:
billingConfig
.
PortRange
.
End
,
},
Listen
_a
ddress
:
addr
,
Listen
A
ddress
:
addr
,
}
file
,
err
:=
json
.
MarshalIndent
(
ftpConfig
,
""
,
" "
)
...
...
@@ -100,7 +87,7 @@ func OpenServer(wg *sync.WaitGroup) *BillingDomain {
logger
.
BillingLog
.
Error
(
"Can't load conf"
,
"Err"
,
errConfig
)
return
nil
}
logger
.
BillingLog
.
Warnf
(
"conf %+v"
,
conf
.
Content
.
Accesses
[
0
]
.
Params
)
// Loading the driver
var
errNewServer
error
b
.
driver
,
errNewServer
=
server
.
NewServer
(
conf
,
logger
.
FtpServerLog
)
...
...
@@ -118,7 +105,7 @@ func OpenServer(wg *sync.WaitGroup) *BillingDomain {
b
.
ftpServer
.
Logger
=
logger
.
FtpServerLog
go
b
.
Serve
()
logger
.
BillingLog
.
Info
(
"Billing server
S
tart"
)
logger
.
BillingLog
.
Info
(
"Billing server
s
tart
ed
"
)
return
b
}
...
...
This diff is collapsed.
Click to expand it.
backend/factory/config.go
+
14
−
7
View file @
21055d60
...
...
@@ -35,7 +35,7 @@ func (c *Config) Validate() (bool, error) {
}
type
Info
struct
{
Version
string
`yaml:"version,omitempty" valid:"required,in(1.0.
2
)"`
Version
string
`yaml:"version,omitempty" valid:"required,in(1.0.
3
)"`
Description
string
`yaml:"description,omitempty" valid:"type(string)"`
}
...
...
@@ -58,17 +58,24 @@ type WebServer struct {
PORT
string
`yaml:"port" valid:"required"`
}
type
Tls
struct
{
type
Cert
struct
{
Pem
string
`yaml:"pem,omitempty" valid:"type(string),minstringlength(1),required"`
Key
string
`yaml:"key,omitempty" valid:"type(string),minstringlength(1),required"`
}
type
PortRange
struct
{
Start
int
`yaml:"start,omitempty" valid:"required" json:"start"`
End
int
`yaml:"end,omitempty" valid:"required" json:"end"`
}
type
BillingServer
struct
{
Enable
bool
`yaml:"enable,omitempty" valid:"required,type(bool)"`
HostIPv4
string
`yaml:"hostIPv4,omitempty" valid:"required,host"`
Port
int
`yaml:"port,omitempty" valid:"optional,port"`
ListenPort
int
`yaml:"listenPort,omitempty" valid:"required,port"`
Tls
*
Tls
`yaml:"tls,omitempty" valid:"optional"`
Enable
bool
`yaml:"enable,omitempty" valid:"required,type(bool)"`
HostIPv4
string
`yaml:"hostIPv4,omitempty" valid:"required,host"`
ListenPort
int
`yaml:"listenPort,omitempty" valid:"required,port"`
PortRange
PortRange
`yaml:"portRange,omitempty" valid:"required"`
BastPath
string
`yaml:"basePath,omitempty" valid:"type(string),required"`
Cert
*
Cert
`yaml:"cert,omitempty" valid:"optional"`
Port
int
`yaml:"port,omitempty" valid:"optional,port"`
}
type
Mongodb
struct
{
...
...
This diff is collapsed.
Click to expand it.
config/webuicfg.yaml
+
8
−
3
View file @
21055d60
info
:
version
:
1.0.
2
version
:
1.0.
3
description
:
WebUI initial local configuration
configuration
:
...
...
@@ -15,10 +15,15 @@ configuration:
enable
:
true
hostIPv4
:
127.0.0.1
listenPort
:
2121
port
:
2122
tls
:
portRange
:
# passive port range
start
:
2123
end
:
2130
basePath
:
/tmp/webconsole
port
:
2122
# CGF's FTP server port (not used for now)
cert
:
pem
:
cert/chf.pem
key
:
cert/chf.key
logger
:
# log output setting
enable
:
true
# true or false
...
...
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