-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from Ola-Mamdouh234/develop
Develop-hashlocal
- Loading branch information
Showing
14 changed files
with
525 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
2546dcffc5ad854d4ddc64fbf056871cd5a00f2471cb7a5bfd4ac23b6e9eedad | ||
e1105070ba828007508566e28a2b8d4c65d192e9eaf3b7868382b7cae747b397 | ||
275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package hashlocal | ||
|
||
import ( | ||
http_message "icapeg/http-message" | ||
"icapeg/logging" | ||
"icapeg/readValues" | ||
services_utilities "icapeg/service/services-utilities" | ||
general_functions "icapeg/service/services-utilities/general-functions" | ||
"net/textproto" | ||
"sync" | ||
//"time" | ||
) | ||
|
||
var doOnce sync.Once | ||
var HashlocalConfig *Hashlocal | ||
|
||
// Hashlookup represents the information regarding the Hashlookup service | ||
type Hashlocal struct { | ||
xICAPMetadata string | ||
httpMsg *http_message.HttpMsg | ||
serviceName string | ||
methodName string | ||
maxFileSize int | ||
bypassExts []string | ||
processExts []string | ||
rejectExts []string | ||
extArrs []services_utilities.Extension | ||
hashfile string | ||
returnOrigIfMaxSizeExc bool | ||
return400IfFileExtRejected bool | ||
generalFunc *general_functions.GeneralFunc | ||
BypassOnApiError bool | ||
FileHash string | ||
CaseBlockHttpResponseCode int | ||
CaseBlockHttpBody bool | ||
ExceptionPage string | ||
IcapHeaders textproto.MIMEHeader | ||
} | ||
|
||
func InitHashlocalConfig(serviceName string) { | ||
logging.Logger.Debug("loading " + serviceName + " service configurations") | ||
doOnce.Do(func() { | ||
HashlocalConfig = &Hashlocal{ | ||
maxFileSize: readValues.ReadValuesInt(serviceName + ".max_filesize"), | ||
bypassExts: readValues.ReadValuesSlice(serviceName + ".bypass_extensions"), | ||
processExts: readValues.ReadValuesSlice(serviceName + ".process_extensions"), | ||
rejectExts: readValues.ReadValuesSlice(serviceName + ".reject_extensions"), | ||
hashfile: readValues.ReadValuesString(serviceName + ".hash_file"), | ||
returnOrigIfMaxSizeExc: readValues.ReadValuesBool(serviceName + ".return_original_if_max_file_size_exceeded"), | ||
return400IfFileExtRejected: readValues.ReadValuesBool(serviceName + ".return_400_if_file_ext_rejected"), | ||
BypassOnApiError: readValues.ReadBoolFromEnv(serviceName + ".bypass_on_api_error"), | ||
CaseBlockHttpResponseCode: readValues.ReadValuesInt(serviceName + ".http_exception_response_code"), | ||
CaseBlockHttpBody: readValues.ReadValuesBool(serviceName + ".http_exception_has_body"), | ||
ExceptionPage: readValues.ReadValuesString(serviceName + ".exception_page"), | ||
} | ||
HashlocalConfig.extArrs = services_utilities.InitExtsArr(HashlocalConfig.processExts, HashlocalConfig.rejectExts, HashlocalConfig.bypassExts) | ||
}) | ||
} | ||
|
||
// NewHashlookupService returns a new populated instance of the Hashlookup service | ||
func NewHashlocalService(serviceName, methodName string, httpMsg *http_message.HttpMsg, xICAPMetadata string) *Hashlocal { | ||
return &Hashlocal{ | ||
xICAPMetadata: xICAPMetadata, | ||
httpMsg: httpMsg, | ||
serviceName: serviceName, | ||
methodName: methodName, | ||
maxFileSize: HashlocalConfig.maxFileSize, | ||
bypassExts: HashlocalConfig.bypassExts, | ||
processExts: HashlocalConfig.processExts, | ||
rejectExts: HashlocalConfig.rejectExts, | ||
extArrs: HashlocalConfig.extArrs, | ||
hashfile: HashlocalConfig.hashfile, | ||
returnOrigIfMaxSizeExc: HashlocalConfig.returnOrigIfMaxSizeExc, | ||
return400IfFileExtRejected: HashlocalConfig.return400IfFileExtRejected, | ||
generalFunc: general_functions.NewGeneralFunc(httpMsg, xICAPMetadata), | ||
BypassOnApiError: HashlocalConfig.BypassOnApiError, | ||
CaseBlockHttpResponseCode: HashlocalConfig.CaseBlockHttpResponseCode, | ||
CaseBlockHttpBody: HashlocalConfig.CaseBlockHttpBody, | ||
ExceptionPage: HashlocalConfig.ExceptionPage, | ||
} | ||
} |
Oops, something went wrong.