Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WRITE-LOGS-FOR-VENDOR.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## **How to write logs for a vendor?**

```go
logging.Logger.Info(utils.PrepareLogMsg(<the X-ICAP-Metadata of the service>, <The message you want to log>))
```
logging.Logger.Debug(utils.PrepareLogMsg(<the X-ICAP-Metadata of the service>, <The message you want to log>))
```
38 changes: 30 additions & 8 deletions api/icap-request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import (
"bytes"
"encoding/json"
"errors"
"icapeg/config"
utils "icapeg/consts"
http_message "icapeg/http-message"
"icapeg/icap"
"icapeg/logging"
"icapeg/service"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net/http"
"strconv"
"strings"
"time"

"github.com/egirna/icapeg/config"
http_message "github.com/egirna/icapeg/http-message"
"github.com/egirna/icapeg/icap"
"github.com/egirna/icapeg/logging"
"github.com/egirna/icapeg/service"
utils "github.com/egirna/icapeg/utils"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

// ICAPRequest struct is used to encapsulate important information of the ICAP request like method name, etc
Expand Down Expand Up @@ -54,7 +58,7 @@ func NewICAPRequest(w icap.ResponseWriter, req *icap.Request) *ICAPRequest {
// and initialize the ICAP response
func (i *ICAPRequest) RequestInitialization() (string, error) {
xICAPMetadata := i.generateICAPReqMetaData(utils.ICAPRequestIdLen)
logging.Logger.Info(utils.PrepareLogMsg(xICAPMetadata, "Validating the received ICAP request"))
logging.Logger.Debug(utils.PrepareLogMsg(xICAPMetadata, "Validating the received ICAP request"))
logging.Logger.Debug(utils.PrepareLogMsg(xICAPMetadata, "Creating an instance from ICAPeg configuration"))
i.appCfg = config.App()

Expand Down Expand Up @@ -117,7 +121,7 @@ func (i *ICAPRequest) RequestInitialization() (string, error) {

// RequestProcessing is a func to process the ICAP request upon the service and method required
func (i *ICAPRequest) RequestProcessing(xICAPMetadata string) {
logging.Logger.Info(utils.PrepareLogMsg(xICAPMetadata,
logging.Logger.Debug(utils.PrepareLogMsg(xICAPMetadata,
"processing ICAP request upon the service and method required"))
partial := false
if i.methodName != utils.ICAPModeOptions {
Expand Down Expand Up @@ -227,6 +231,24 @@ func (i *ICAPRequest) RespAndReqMods(partial bool, xICAPMetadata string) {
//icap.Request.Response
IcapStatusCode, httpMsg, serviceHeaders, httpMshHeadersBeforeProcessing, httpMshHeadersAfterProcessing,
vendorMsgs := requiredService.Processing(partial, i.req.Header)
// Create an array of zap.String Fields from the service headers map
// and add them to the logger
fields := make([]zapcore.Field, 0, 5+len(serviceHeaders)+len(httpMshHeadersBeforeProcessing)+len(httpMshHeadersAfterProcessing))
fields = append(fields, zap.String("X-ICAP-Metadata", xICAPMetadata))
fields = append(fields, zap.String("mode", i.methodName))
fields = append(fields, zap.String("vendor", i.vendor))
fields = append(fields, zap.String("service", i.serviceName))
fields = append(fields, zap.Int("icap_status", IcapStatusCode))
for k, v := range serviceHeaders {
fields = append(fields, zap.String(fmt.Sprintf("icap_header_%s", k), v))
}
for k, v := range httpMshHeadersBeforeProcessing {
fields = append(fields, zap.String(fmt.Sprintf("http_header_before_%s", k), fmt.Sprintf("%v", v)))
}
for k, v := range httpMshHeadersAfterProcessing {
fields = append(fields, zap.String(fmt.Sprintf("http_header_after_%s", k), fmt.Sprintf("%v", v)))
}
logging.Logger.Info(i.req.URL.String(), fields...)

// adding the headers which the service wants to add them in the ICAP response
logging.Logger.Debug(utils.PrepareLogMsg(xICAPMetadata,
Expand Down
6 changes: 3 additions & 3 deletions api/icap.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package api

import (
"icapeg/icap"
"icapeg/logging"
"github.com/egirna/icapeg/icap"
"github.com/egirna/icapeg/logging"
)

// ToICAPEGServe is the ICAsP Request Handler for all modes and services:
func ToICAPEGServe(w icap.ResponseWriter, req *icap.Request) {
logging.Logger.Info("a request was sent to ICAPeg")
logging.Logger.Debug("a request was sent to ICAPeg")
//Creating new instance from struct IcapRequest yo handle upcoming ICAP requests
ICAPRequest := NewICAPRequest(w, req)

Expand Down
7 changes: 4 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package config

import (
"fmt"
"icapeg/logging"
"icapeg/readValues"
"os"

"github.com/egirna/icapeg/logging"
"github.com/egirna/icapeg/readValues"

"github.com/spf13/viper"
)

Expand Down Expand Up @@ -55,7 +56,7 @@ func Init() {
Services: readValues.ReadValuesSlice("app.services"),
}
logging.InitializeLogger(AppCfg.LogLevel, AppCfg.WriteLogsToConsole)
logging.Logger.Info("Reading config.toml file")
logging.Logger.Debug("Reading config.toml file")

//this loop to make sure that all services in the array of services has sections in the config file and from request mode and response mode
//there is one at least from them are enabled in every service
Expand Down
139 changes: 0 additions & 139 deletions freebsd/0001-security-icapeg-release-v1.0.0.patch

This file was deleted.

70 changes: 70 additions & 0 deletions freebsd/0001-www-icapeg-release-v1.0.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From d3cb028b4e8425721e670b32a0592a2bb46fc295 Mon Sep 17 00:00:00 2001
From: Khaled Emara <support@egirna.com>
Date: Fri, 5 May 2023 13:40:01 +0200
Subject: [PATCH] www/icapeg: release v1.0.0

Signed-off-by: Khaled Emara <support@egirna.com>
---
www/icapeg/Makefile | 26 ++++++++++++++++++++++++++
www/icapeg/distinfo | 5 +++++
www/icapeg/pkg-descr | 3 +++
3 files changed, 34 insertions(+)
create mode 100644 www/icapeg/Makefile
create mode 100644 www/icapeg/distinfo
create mode 100644 www/icapeg/pkg-descr

diff --git a/www/icapeg/Makefile b/www/icapeg/Makefile
new file mode 100644
index 000000000..a05e9bbfb
--- /dev/null
+++ b/www/icapeg/Makefile
@@ -0,0 +1,26 @@
+PORTNAME= icapeg
+DISTVERSIONPREFIX= v
+DISTVERSION= 1.0.0
+CATEGORIES= www
+
+MAINTAINER= support@egirna.com
+COMMENT= An ICAP server implementation
+WWW= https://github.com/egirna/icapeg
+
+LICENSE= APACHE20
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+USES= go:modules
+GO_MODULE= github.com/egirna/icapeg
+
+post-install:
+ ${MKDIR} ${STAGEDIR}${ETCDIR}
+ ${INSTALL_DATA} ${WRKSRC}/config.toml ${STAGEDIR}${ETCDIR}/config.toml.sample
+ ${MKDIR} ${STAGEDIR}${DATADIR}
+ ${INSTALL_DATA} ${WRKSRC}/temp/exception-page.html ${STAGEDIR}${DATADIR}/exception-page.html
+
+PLIST_FILES= bin/icapeg \
+ "@sample ${ETCDIR}/config.toml.sample" \
+ "${DATADIR}/exception-page.html"
+
+.include <bsd.port.mk>
diff --git a/www/icapeg/distinfo b/www/icapeg/distinfo
new file mode 100644
index 000000000..f9872291b
--- /dev/null
+++ b/www/icapeg/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1683286476
+SHA256 (go/www_icapeg/icapeg-v1.0.0/v1.0.0.mod) = f5dd506f5a783d79a500114ddb1606065ed43794743d9de63324349289436778
+SIZE (go/www_icapeg/icapeg-v1.0.0/v1.0.0.mod) = 1066
+SHA256 (go/www_icapeg/icapeg-v1.0.0/v1.0.0.zip) = 4ada6aa16317641f532574aad25dd993ad014502d9a2ab7f90a3ebf650c62319
+SIZE (go/www_icapeg/icapeg-v1.0.0/v1.0.0.zip) = 5941840
diff --git a/www/icapeg/pkg-descr b/www/icapeg/pkg-descr
new file mode 100644
index 000000000..aa2e06a83
--- /dev/null
+++ b/www/icapeg/pkg-descr
@@ -0,0 +1,3 @@
+icapeg is an implementation of an ICAP server. It can be used with HTTP proxies
+that support the ICAP protocol to implement content adaptation and filtering
+services.
--
2.39.2

Binary file modified freebsd/FreeBSD Ports.pdf
Binary file not shown.
31 changes: 3 additions & 28 deletions freebsd/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PORTNAME= icapeg
PORTVERSION= 1.0.0
DISTVERSIONPREFIX= v
CATEGORIES= security
DISTVERSION= 1.0.0
CATEGORIES= www

MAINTAINER= support@egirna.com
COMMENT= An ICAP server implementation
Expand All @@ -11,32 +11,7 @@ LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE

USES= go:modules
USE_GITHUB= yes
GH_ACCOUNT= egirna
GH_TUPLE= \
davecgh:go-spew:v1.1.1:davecgh_go_spew/vendor/github.com/davecgh/go-spew \
dutchcoders:go-clamd:b970184f4d9e:dutchcoders_go_clamd/vendor/github.com/dutchcoders/go-clamd \
fsnotify:fsnotify:v1.5.1:fsnotify_fsnotify/vendor/github.com/fsnotify/fsnotify \
go-ini:ini:v1.63.2:go_ini_ini/vendor/gopkg.in/ini.v1 \
go-yaml:yaml:v2.4.0:go_yaml_yaml/vendor/gopkg.in/yaml.v2 \
golang:sys:63515b42dcdf:golang_sys/vendor/golang.org/x/sys \
golang:text:v0.3.6:golang_text/vendor/golang.org/x/text \
h2non:filetype:v1.0.12:h2non_filetype/vendor/github.com/h2non/filetype \
hashicorp:hcl:v1.0.0:hashicorp_hcl/vendor/github.com/hashicorp/hcl \
magiconair:properties:v1.8.5:magiconair_properties/vendor/github.com/magiconair/properties \
mitchellh:mapstructure:v1.4.2:mitchellh_mapstructure/vendor/github.com/mitchellh/mapstructure \
pelletier:go-toml:v1.9.4:pelletier_go_toml/vendor/github.com/pelletier/go-toml \
pkg:errors:v0.9.1:pkg_errors/vendor/github.com/pkg/errors \
spf13:afero:v1.6.0:spf13_afero/vendor/github.com/spf13/afero \
spf13:cast:v1.4.1:spf13_cast/vendor/github.com/spf13/cast \
spf13:jwalterweatherman:v1.1.0:spf13_jwalterweatherman/vendor/github.com/spf13/jwalterweatherman \
spf13:pflag:v1.0.5:spf13_pflag/vendor/github.com/spf13/pflag \
spf13:viper:v1.9.0:spf13_viper/vendor/github.com/spf13/viper \
subosito:gotenv:v1.2.0:subosito_gotenv/vendor/github.com/subosito/gotenv \
uber-go:atomic:v1.10.0:uber_go_atomic/vendor/go.uber.org/atomic \
uber-go:multierr:v1.8.0:uber_go_multierr/vendor/go.uber.org/multierr \
uber-go:zap:v1.22.0:uber_go_zap/vendor/go.uber.org/zap \
xhit:go-str2duration:v2.0.0:xhit_go_str2duration_v2/vendor/github.com/xhit/go-str2duration/v2
GO_MODULE= github.com/egirna/icapeg

post-install:
${MKDIR} ${STAGEDIR}${ETCDIR}
Expand Down
Loading