Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase library callback functionality to have parity with fields available in output. #969

Open
aringo-bf opened this issue Feb 20, 2024 · 2 comments
Assignees
Labels
Type: Enhancement Most issues will probably ask for additions or changes. Type: Question A query or seeking clarification on parts of the spec. Probably doesn't need the attention of all.

Comments

@aringo-bf
Copy link

aringo-bf commented Feb 20, 2024

Hello, hopefully this is correct:

Looking at the library the functionality for the callback seems to give access to just *result.HostResult

OnResult:  func(hr *result.HostResult) {}

Result pkg

type HostResult struct {
	Host  string
	IP    string
	Ports []*port.Port
}

The runner pkg has stuff like this in output.go with values not available on the callback

type Result struct {
	Host      string    `json:"host,omitempty" csv:"host"`
	IP        string    `json:"ip,omitempty" csv:"ip"`
	Port      int       `json:"port,omitempty" csv:"port"`
	Protocol  string    `json:"protocol,omitempty" csv:"protocol"`
	TLS       bool      `json:"tls,omitempty" csv:"tls"`
	IsCDNIP   bool      `json:"cdn,omitempty" csv:"cdn"`
	CDNName   string    `json:"cdn-name,omitempty" csv:"cdn-name"`
	TimeStamp time.Time `json:"timestamp,omitempty" csv:"timestamp"`
}

Would it be possible to give users of the library access to as much data as Result? It doesn't have the combined port in that one.

Describe the use case of this feature:

This would give library users easier access to output values available in the program.

@aringo-bf aringo-bf added the Type: Enhancement Most issues will probably ask for additions or changes. label Feb 20, 2024
@Mzack9999
Copy link
Member

All the values are already accessible in HostResult (each port carries info about the protocol and tls). Are you mostly interested in the CDN info?

@Mzack9999 Mzack9999 added the Type: Question A query or seeking clarification on parts of the spec. Probably doesn't need the attention of all. label Mar 15, 2024
@Mzack9999 Mzack9999 self-assigned this Mar 15, 2024
@aringo-bf
Copy link
Author

Yes, it was originally about the CDN value but it's also about ease of usability.

The results are returned in a - concacted string for some unknown to me reason so that leaves a lot to be desired. To easily access the properties of the port or if it's TLS you have to as far as I know make some stupid function like below.

                var port, protocol int, var tls bool
		// fix hard to work with return values 
                 formattedString := fmt.Sprintf("%d-%d-%v", elem.Port, elem.Protocol, elem.TLS)
		_, err := fmt.Sscanf(formattedString, "%d-%d-%v", &port, &protocol, &tls)

Why not just return the result struct ?

Ended up just calling CDN check directly to access those values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Most issues will probably ask for additions or changes. Type: Question A query or seeking clarification on parts of the spec. Probably doesn't need the attention of all.
Projects
None yet
Development

No branches or pull requests

2 participants