Files
gluetun/internal/logging/splash.go

62 lines
1.8 KiB
Go
Raw Normal View History

2021-02-06 16:26:23 +00:00
// Package logging defines helper functions for logging.
package logging
import (
"fmt"
"strings"
"time"
2020-07-26 12:07:06 +00:00
"github.com/qdm12/gluetun/internal/constants"
2020-11-04 14:07:04 +00:00
"github.com/qdm12/gluetun/internal/models"
)
2020-10-20 02:45:28 +00:00
// Splash returns the welcome spash message.
2020-11-04 14:07:04 +00:00
func Splash(buildInfo models.BuildInformation) string {
lines := title()
lines = append(lines, "")
2020-11-04 14:07:04 +00:00
lines = append(lines, fmt.Sprintf("Running version %s built on %s (commit %s)",
buildInfo.Version, buildInfo.BuildDate, buildInfo.Commit))
lines = append(lines, "")
lines = append(lines, announcement()...)
lines = append(lines, "")
lines = append(lines, links()...)
return strings.Join(lines, "\n")
}
func title() []string {
return []string{
"=========================================",
"================ Gluetun ================",
"=========================================",
"==== A mix of OpenVPN, DNS over TLS, ====",
"======= Shadowsocks and HTTP proxy ======",
"========= all glued up with Go ==========",
"=========================================",
"=========== For tunneling to ============",
"======== your favorite VPN server =======",
"=========================================",
"=== Made with ❤️ by github.com/qdm12 ====",
"=========================================",
}
}
func announcement() []string {
if len(constants.Announcement) == 0 {
2020-02-25 11:46:52 +00:00
return nil
}
expirationDate, _ := time.Parse("2006-01-02", constants.AnnouncementExpiration) // error covered by a unit test
2020-02-25 11:46:52 +00:00
if time.Now().After(expirationDate) {
return nil
}
return []string{"📣" + constants.Announcement}
}
func links() []string {
return []string{
"🔧 Need help? " + constants.IssueLink,
"💻 Email? quentin.mcgaw@gmail.com",
"☕ Slack? Join from the Slack button on Github",
"💰 Help me? https://github.com/sponsors/qdm12",
}
}