reflection work so far...
This commit is contained in:
60
funcs_reflecturi.go
Normal file
60
funcs_reflecturi.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package cryptparse
|
||||
|
||||
import (
|
||||
`reflect`
|
||||
`strconv`
|
||||
)
|
||||
|
||||
/*
|
||||
reflectUriFlat is the reflection used for a TlsUri when converting to a TlsFlat.
|
||||
*/
|
||||
func reflectUriFlat(s *TlsUri, tagName string) (f *TlsFlat, err error) {
|
||||
|
||||
var ptrVal reflect.Value
|
||||
var ptrType reflect.Type
|
||||
var ptrKind reflect.Kind
|
||||
var n uint64
|
||||
var flat TlsFlat
|
||||
var sVal reflect.Value = reflect.ValueOf(s)
|
||||
var sType reflect.Type = sVal.Type()
|
||||
var kind reflect.Kind = sType.Kind()
|
||||
var params map[tlsUriParam][]string = make(map[tlsUriParam][]string)
|
||||
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range params {
|
||||
if tlsUriParam(k) != "" {
|
||||
params[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
flat = TlsFlat{
|
||||
Host: s.Hostname(),
|
||||
Port: nil,
|
||||
SniName: nil,
|
||||
SkipVerify: false,
|
||||
Certs: nil,
|
||||
CaFiles: nil,
|
||||
CipherSuites: nil,
|
||||
Curves: nil,
|
||||
MinTlsProtocol: nil,
|
||||
MaxTlsProtocol: nil,
|
||||
}
|
||||
|
||||
if s.Port() != "" {
|
||||
f.Port = new(uint16)
|
||||
if n, err = strconv.ParseUint(s.Port(), 10, 16); err != nil {
|
||||
return
|
||||
}
|
||||
*f.Port = uint16(n)
|
||||
}
|
||||
|
||||
// TODO: lookup map, map[string]tlsUriParam where key is name of constant as string, and value is that corresponding value.
|
||||
// Use that value to lookup in params.
|
||||
|
||||
f = &flat
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user