Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:crameleon:misc
go-mmproxy
gh-pr-31_comments.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gh-pr-31_comments.patch of Package go-mmproxy
From 96395a5a8d028b18b824614affda819511656b86 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net> Date: Sun, 26 May 2024 16:48:27 +0200 Subject: [PATCH] Skip comments and empty lines in subnets file Make parsing more resilient and allow for annotations. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net> --- main.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index aa67bc5..56a21a0 100644 --- a/main.go +++ b/main.go @@ -84,12 +84,15 @@ func loadAllowedSubnets() error { scanner := bufio.NewScanner(file) for scanner.Scan() { - _, ipNet, err := net.ParseCIDR(scanner.Text()) - if err != nil { - return err + line := scanner.Text() + if len(line) > 0 && line[0] != '#' { + _, ipNet, err := net.ParseCIDR(line) + if err != nil { + return err + } + Opts.AllowedSubnets = append(Opts.AllowedSubnets, ipNet) + Opts.Logger.Info("allowed subnet", slog.String("subnet", ipNet.String())) } - Opts.AllowedSubnets = append(Opts.AllowedSubnets, ipNet) - Opts.Logger.Info("allowed subnet", slog.String("subnet", ipNet.String())) } return nil
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor