We used to ride on the native reserve near my home town, and it was off-leash dog central!
My advice is - if you have time to evaluate and consider a dog's mood and intentions, you probably have time to get your water bottle out and give the pupper a squirt in the face with some dihydrogen-monoxide if it gets too close. The dog will stop in his tracks regardless of its intentions before he got a snoot full of cold water.