Skip to content

Conversation

larsxschneider
Copy link
Member

It can be hard to trace Git LFS errors on the server without client IP
address. Fix this by adding the IP address to the error log output.

Attention

Is this OK from a privacy perspective? I think it is OK as we log the file to the local machine that knows the IP address anyways. A user that is concerned about the IP address could remove it from an error report. The same is already the case if the error output contains sensitive filenames of a repo.

continue
}
s = s + ip.String() + " "
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got heavily inspired here: https://stackoverflow.com/a/23558495 ;-)

Copy link
Contributor

@ttaylorr ttaylorr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@larsxschneider great work here, I have a few comments below, but after addressing those this should be ready to merge.

case *net.IPAddr:
ip = v.IP
}
if ip == nil || ip.IsLoopback() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this check go before the switch above? You could have something like (*net.IPNet)(nil), which would panic on L362 after trying to dereference it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if I understand you right, but this doesn't panic:

                        addr = nil
			var ip net.IP
			switch v := addr.(type) {
			case *net.IPNet:
				ip = v.IP
			case *net.IPAddr:
				ip = v.IP
			}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 totally disregard my suggestion -- I misread your code as if addr == nill || addr.IsLoopback(), instead of ip. This is all good 👍

if ip == nil || ip.IsLoopback() {
continue
}
s = s + ip.String() + " "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a " " on the end of s here, could you use a []string and call strings.Join(slice, " ") to prevent the trailing whitespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

It can be hard to trace Git LFS errors on the server without client IP
address. Fix this by adding the IP address to the error log output.
@larsxschneider
Copy link
Member Author

@ttaylorr I fixed the string issue in a rebase!

@ttaylorr ttaylorr merged commit fe23c52 into master Sep 11, 2017
@ttaylorr ttaylorr added this to the v2.3.0 milestone Sep 11, 2017
@technoweenie technoweenie deleted the lars/ips branch September 11, 2017 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants